这里对lis<map<String,Strig>>日期list的排序记录一下。
public class listComparator implements Comparator<Map<String, String>>{
@Override
public int compare(Map<String, String> o1, Map<String, String> o2) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d1 = null;
Date d2 = null;
for (String k : o1.keySet()) {
try {
if(o1.get(k) != null && !("".equals(o1.get(k)))){
d1 = format.parse(o1.get(k));
}
} catch (java.text.ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
for (String k : o2.keySet()) {
try {
if(o2.get(k) != null && !("".equals(o2.get(k)))){
d2 = format.parse(o2.get(k));
}
} catch (java.text.ParseException e) {
e.printStackTrace();
}
}
if (d1.after(d2)) {
return 1;
} else if (d1.before(d2)) {
return -1;
} else {
return 0;
}
}
}