码迷,mamicode.com
首页 > 其他好文 > 详细

代码学习

时间:2017-09-27 19:01:50      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:blog   simple   date   ring   return   public   .so   for   trace   

1.

public void compareList(final List resultList) {
        Collections.sort(resultList, new Comparator<Map>() {
            @Override
            public int compare(Map o1, Map o2) {
                Date date1 = null;
                Date date2 = null;
                DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
                if (o1.get("DUE_TIME") != null && o2.get("DUE_TIME") != null) {
                    try {
                        date1 = fmt.parse(String.valueOf(o1.get("DUE_TIME")));
                        date2 = fmt.parse(String.valueOf(o2.get("DUE_TIME")));
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    if (date1.getTime() > date2.getTime()) {
                        return 1;
                    }
                    if (date2.getTime() > date1.getTime()) {
                        return 0;
                    }
                    return 1;
                }
                return 0;
            }
        });
    }

 

代码学习

标签:blog   simple   date   ring   return   public   .so   for   trace   

原文地址:http://www.cnblogs.com/hongyedeboke/p/7603002.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!