java compare 时间排序
所有数据存进resultList中
Collections.sort(resultList, new Comparator<HashMap<String, Object>>() {
@Override
public int compare(HashMap<String, Object> o1, HashMap<String, Object> o2) {
Date time1 = (Date) o1.get("submitTime");
Date time2 = (Date) o2.get("submitTime");
if (null == time1) {
return 1;
}
if (null == time2) {
return -1;
}
return time2.compareTo(time1); //按时间正序 倒叙是 time1.compareTo(time2);
}
});