使用joda从开始和结束找到天数差异?

这个问题在这里已经有了答案:

  • Joda-Time中的两个日期之间的天数6个答案

  • 使用Joda图书馆的Days Days

    Days days=Days.daysBetween(startDate.toLocalDate(), endDate.toLocalDate()).getDays();
    int noOfDays=days.getDays();
    

    作为替代,我们也可以使用Java 8 日期和时间API

    public void days_between_two_dates_in_java_with_java8 () {
    
        LocalDate startDate = LocalDate.now().minusDays(1);
        LocalDate endDate = LocalDate.now();
    
        long days = Period.between(startDate, endDate).getDays();
    
    
        // or 
    
        long days2 = ChronoUnit.DAYS.between(startDate, endDate);
    
    }
    
    链接地址: http://www.djcxy.com/p/36657.html

    上一篇: Finding difference of days from start and end using joda?

    下一篇: How to compare dates in Android app?