首页 > 其他 > 详细

代码学习

时间:2017-09-27 18:12:09      阅读:190      评论:0      收藏:0      [点我收藏+]

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;
            }
        });
    }

 

代码学习

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!