List<Map> maps=new ArrayList<>();
//对maps进行赋值
Comparator comp = new Comparator() {
@Override
public int compare(Object o1, Object o2) {
Map<String, Object> mapO1 = (Map<String, Object>) o1;
Map<String, Object> mapO2 = (Map<String, Object>) o2;
Date date1 = new Date();
Date date2 = new Date();
try {
date1 = DateUtil.string2Date(mapO1.get("createDate").toString());
date2 = DateUtil.string2Date(mapO2.get("createDate").toString());
} catch (Exception e) {
e.printStackTrace();
}
if (date1.compareTo(date2) > 0) {
return 1;
} else {
return -1;
}
}
};
Collections.sort(maps, comp);