From 3625ec04d2651898e2955c62be3e260e6d274366 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Thu, 15 Apr 2021 12:03:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=88=97=E8=A1=A8=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DgEfficiencyServiceImpl.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java index 1e10feba..b8d894bb 100644 --- a/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java +++ b/dq-financial-guarantee/src/main/java/com/daqing/financial/guarantee/service/impl/DgEfficiencyServiceImpl.java @@ -618,7 +618,6 @@ public class DgEfficiencyServiceImpl extends ServiceImpl nowList = this.ListSort(list); + return nowList; + } + + /** + * 根据时间排序(其他排序如根据id排序也类似) + * @param list + */ + public List ListSort(List list) { + //用Collections这个工具类传list进来排序 + Collections.sort(list, new Comparator() { + @Override + public int compare(DgNoticeListResponse o1, DgNoticeListResponse o2) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + Date dt1 = format.parse(format.format(o1.getCreateTime())); + Date dt2 = format.parse(format.format(o2.getCreateTime())); + if (dt1.getTime() > dt2.getTime()) { + return -1;//大的放前面 + }else { + return 1; + } + } catch (Exception e) { + e.printStackTrace(); + } + return 0; + } + }); return list; } + } \ No newline at end of file