private static void ListSort(List list) {
//用Collections这个工具类传list进来排序
Collections.sort(list, new Comparator() {
@Override
public int compare(HdCase o1, HdCase o2) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
String str1=format.format(o1.getCreateDate());
String str2=format.format(o2.getCreateDate());
Date dt1 = format.parse(str1);
Date dt2 = format.parse(str2);
if (dt1.getTime() > dt2.getTime()) {
return 1;//小的放前面
}else {
return -1;
}
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
});
}

相关文章:

  • 2022-12-23
  • 2021-07-31
  • 2022-12-23
  • 2021-05-23
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-21
  • 2021-07-09
  • 2022-12-23
  • 2021-11-23
  • 2021-09-29
  • 2022-12-23
相关资源
相似解决方案