//实体类 AtomOrderList
//需要遍历的list List<AtomOrderList> list
private List<AtomOrderList> listSort(List<AtomOrderList> list) {
//这边时间格式根据具体情况而定
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date d1;
Date d2;
AtomOrderList temp = new AtomOrderList();
//冒泡排序
for (int i = 0; i < list.size(); i++) {
for (int j = i+1; j < list.size(); j++) {
ParsePosition pos1 = new ParsePosition(0);
ParsePosition pos2 = new ParsePosition(0);
if (null != list.get(i).getCreateDate() &&
null != list.get(j).getCreateDate()){
d1 = sdf.parse(list.get(i).getCreateDate(),pos1);
d2 = sdf.parse(list.get(j).getCreateDate(),pos2);
if (d1.before(d2)){
temp = list.get(i);
list.set(i,list.get(j));
list.set(j,temp);
}
}
}
}
System.out.println(list);
return list;
}