其他分享
首页 > 其他分享> > List根据时间字符串排序

List根据时间字符串排序

作者:互联网

Collections.sort(resList, new Comparator<LoanApplyLogRes>() {
@Override
public int compare(LoanApplyLogRes o1, LoanApplyLogRes o2) {
SimpleDateFormat format = new SimpleDateFormat(DateUtil.DATE_TIME_FORMAT);
try {
Date dt1 = format.parse(o1.getOperateTime());
Date dt2 = format.parse(o2.getOperateTime());
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;
}
});

标签:return,format,getTime,List,parse,字符串,dt2,dt1,排序
来源: https://www.cnblogs.com/maohuidong/p/10405559.html