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