Java计算时间差

  SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        long time = simpleDateFormat.parse("2020-6-29 9:40").getTime();
        long time1 = simpleDateFormat.parse("2020-6-29 10:30").getTime();
        long minutes = ChronoUnit.MINUTES.between(Instant.ofEpochMilli(time), Instant.ofEpochMilli(time1));
        System.out.println(minutes);

  

posted @ 2020-06-29 09:51  辰梓悦  阅读(296)  评论(0编辑  收藏  举报