list元素按照日期排序


private static void ListSort(List<AppClassInfoVo> list) {
Collections.sort(list, new Comparator<AppClassInfoVo>() {
@Override
public int compare(AppClassInfoVo n1, AppClassInfoVo n2) {
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date dt1 = format.parse(n1.getCreatedate()+"");
Date dt2 = format.parse(n2.getCreatedate()+"");
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;
}
});
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM