Java 无法使用joda time获得两个日期之间的正确差异

Java 无法使用joda time获得两个日期之间的正确差异,java,jodatime,Java,Jodatime,我试图用乔达时间来计算这两个日期之间的差异,但不知何故,我无法得到确切的差异 LocalDate endofCentury = new LocalDate(2014, 01, 01); LocalDate now = LocalDate.now(); //2017-04-11 Period diff = new Period(endofCentury, now); System.out.printf("Difference

我试图用乔达时间来计算这两个日期之间的差异,但不知何故,我无法得到确切的差异

        LocalDate endofCentury = new LocalDate(2014, 01, 01);

        LocalDate now = LocalDate.now(); //2017-04-11

        Period diff = new Period(endofCentury, now); 

        System.out.printf("Difference is %d years, %d months and %d days old", 
                            diff.getYears(), diff.getMonths(), diff.getDays());
差异应为3年、3个月、10天,但我将3年、3个月和3天

不知道我错过了什么,请帮我解决


谢谢

使用带3个参数的构造函数:

Period diff=new Period(endofCentury,now,PeriodType.yearMonthDay())

具有两个参数
(from,to)
的构造函数包括周

因此,代码的修改输出:

Period diff = new Period(endofCentury, now);
System.out.printf("Difference is %d years, %d months and %d weeks and %d days old",
                diff.getYears(), diff.getMonths(),diff.getWeeks(), diff.getDays());
给出输出:

差异为3年、3个月、1周和3天

但具有指定的持续时间字段(第三个参数):

你会得到:

差异为3年、3个月、0周和10天


请参阅:

谢谢@Jérôme。这个解决方案对我有效。
Period diff = new Period(endofCentury, now, PeriodType.yearMonthDay());
System.out.printf("Difference is %d years, %d months and %d weeks and %d days old",
            diff.getYears(), diff.getMonths(),diff.getWeeks(), diff.getDays());