当前位置:   article > 正文

ChronoUnit 计算日期时间差(java用法)_chronounit.days.between

chronounit.days.between

        LocalDateTime today = LocalDateTime.now();
        LocalDateTime birthDate = LocalDateTime.of(2000, 05, 31, 0, 0, 0, 0);
 
        "相差的年数: "  ChronoUnit.YEARS.between(birthDate,today);
        "相差的月数: "  ChronoUnit.MONTHS.between(birthDate,today);
        "相差的周数: "  ChronoUnit.WEEKS.between(birthDate,today);
        "相差的天数: "  ChronoUnit.DAYS.between(birthDate,today);
        "相差的时数: "  ChronoUnit.HOURS.between(birthDate, today);
        "相差的分数: "  ChronoUnit.MINUTES.between(birthDate, today);
        "相差的秒数: "  ChronoUnit.SECONDS.between(birthDate,today);
        "相差的毫秒数: "  ChronoUnit.MILLIS.between(birthDate,today);
        "相差的微秒数: "  ChronoUnit.MICROS.between(birthDate,today);
        "相差的纳秒数: "  ChronoUnit.NANOS.between(birthDate, today);
        "相差的半天数: "  ChronoUnit.HALF_DAYS.between(birthDate, today);
        "相差的十年数: "  ChronoUnit.DECADES.between(birthDate,today);
        "相差的世纪有年数: "  ChronoUnit.CENTURIES.between(birthDate,today);
        "相差的千年数: "  ChronoUnit.MILLENNIA.between(birthDate,today);
        "相差的纪元数: "  ChronoUnit.ERAS.between(birthDate,today);

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/549284
推荐阅读
相关标签
  

闽ICP备14008679号