【发布时间】:2016-01-13 23:32:40
【问题描述】:
我正在做一些单元测试,并且发生过这种情况:
2015 年(不是闰年)
LocalDate endDate = LocalDate.parse("01/03/2015", new DateTimeFormatterFactory("dd/MM/yyyy").createDateTimeFormatter());
LocalDate startDate = LocalDate.parse("25/02/2015", new DateTimeFormatterFactory("dd/MM/yyyy").createDateTimeFormatter());
org.joda.time.Period.fieldDifference(startDate, endDate).getDays(); // is -24
2016(闰年)
LocalDate endDate = LocalDate.parse("01/03/2016", new DateTimeFormatterFactory("dd/MM/yyyy").createDateTimeFormatter());
LocalDate startDate = LocalDate.parse("25/02/2016", new DateTimeFormatterFactory("dd/MM/yyyy").createDateTimeFormatter());
org.joda.time.Period.fieldDifference(startDate, endDate).getDays(); // is ALSO -24
我希望这些值至少有所不同。
有什么想法吗?
【问题讨论】:
-
糟糕。那是示例中的错字,我现在已经修复了。