list集合对象日期排序

1.Collections.sort排序
 List<DateObj> list = mongoDAO.findByQuery(query,DateObj.class);
        Collections.sort(list, new Comparator<DateObj>() {
            @Override
            public int compare(DateObjo1, DateObjo2) {
                if(o1.getEntryTime()-o2.getEntryTime()==0)
                    return 0;
                return o1.getEntryTime()-o2.getEntryTime()>0?-1:1;
            }
        });
//EntryTime自动为long

 

posted @ 2021-10-20 13:18  回溯者  阅读(352)  评论(0编辑  收藏  举报