public static void main(String[] args) throws ParseException {    //  sort降序排列
        List<Date> dates = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date dd = sdf.parse("2000-11-11 12:12:21");
        Date aa = sdf.parse("2002-11-11 12:12:21");
        Date date = new Date();


        dates.add(date);
        dates.add(dd);
        dates.add(aa);
        Collections.sort(dates, new Comparator<Date>() {

            @Override
            public int compare(Date o1, Date o2) {
                int flag = o2.compareTo(o1);
                return flag;
            }
        });

        System.out.println(dates.get(0));
    }

 

相关文章:

  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2021-12-23
  • 2021-11-09
  • 2021-08-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-29
  • 2022-01-24
  • 2021-11-16
  • 2021-12-23
  • 2021-10-24
相关资源
相似解决方案