(1) 自己写循环,一个一个比较
    Date[] dates = ...
    Date min = null;
    Date max = null;
    for(int i=0; i<dates.length; i++) {
        if(i==0) {
            min = dates[i];
            max = dates[i];
        } else {
            if(dates[i].compareTo(min)<0) {min=dates[i];}
            if(dates[i].compareTo(max)>0) {max=dares[i];}
        }
    }
(2) 用SortedSet.
    Date[] dates = ...;
    SortedSet set = new TreeSet(Arrays.asList(dates));
    Date min = set.first();
    Date max = set.last();

解决方案 »

  1.   

    Date 对象的compareTo 可以比较
    也可以用 Date 对象的 getTime() 取得一个 long 值来比较。有比较办法之后要查最大最小的就不用多说了吧?!
      

  2.   

    使用SortedSet方法最简单,Date实现了Comparable
    接口,可以放入到SortedSet里面
      

  3.   

    还以吧日期对象保存在map中..
    通过treemap利用Comparable接口排序
      

  4.   

    public int compare(Object o1, Object o2) {
            Date d1=(Date)o1;
            Date d2=(Date)o2;
            if(d1.after(d2)){
                return 1;
                }
            return 0;
        }
    看错了,以为是比较List里面的数据。
      

  5.   

    class ListSort {    public static void main(String[] args) {        List list = new ArrayList();
            Date[] array = new Date[100];
            ..........//
            List resutList = Arrays.asList(array);
            Comparator c = new Follow();
            Collections.sort(resutList, c);
        }}class Follow implements Comparator {
        Follow(){            
        }
        public int compare(Object o1, Object o2) {
            Date d1 = (Date) o1;
            Date d2 = (Date) o2;
            if (d1.after(d2)) {
                return 1;
            }
            return 0;
        }
    }