java ArrayList排序

Collections.sort(mPersons, new Comparator<Object>() {
        @Override
        public int compare(Object o1, Object o2) {
          Person p1=(Person)o1;
             Person p2=(Person)o2; 
          SimpleDateFormat df =new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
     try {
      return df.parse(p1.getPctime()).compareTo(df.parse(p2.getPctime()));
     } catch (ParseException e) {
      return 0;
     }
        }
      });

posted on 2014-05-07 15:48  劉劉  阅读(97)  评论(0)    收藏  举报