获取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)