List根据时间字符串排序

Posted maohuidong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
}
});




















以上是关于List根据时间字符串排序的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript根据字符串末尾值分组并排序isArraythrowTypeErrorsubstring

python 排序,根据字符长度,数字,字母

python 排序,根据字符长度,数字,字母

Python中字符串列表的排序列表[重复]

根据两个或多个值对通用列表进行排序

如何对List集合中的对象进行排序?