获取List集合中最大的日期时间

   public static void main(String[] args) {
        List<Date> dateList=new ArrayList<>();
        Date date=new Date();
        dateList.add(date);
        System.out.println(date);

        dateList.add(DateUtil.limitDate(date,1));
        System.out.println(DateUtil.limitDate(date,1));

        System.out.println(Collections.max(dateList));
    }

 输出结果:

Sun Apr 24 14:13:51 CST 2022
Sun Apr 24 15:13:51 CST 2022
Sun Apr 24 15:13:51 CST 2022

  

Collections.max(dateList)

posted @ 2022-04-24 14:19  ni当像鸟飞往你的山  阅读(1347)  评论(0编辑  收藏  举报