/**
* 根据时间排序
* @param list
*/
private static void userRechargeListSort(List<UserRecharge> list) {
Collections.sort(list, new Comparator<UserRecharge>() {
@Override
public int compare(UserRecharge o1, UserRecharge o2) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date dt1 = format.parse(o1.getCreateTime());
Date dt2 = format.parse(o2.getCreateTime());
if (dt1.getTime() > dt2.getTime()) {
return -1;
} else if (dt1.getTime() < dt2.getTime()) {
return 1;
} else {
return 0;
}
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
});
}
转载于:https://www.cnblogs.com/zfzf1/p/10471983.html