有没有办法只有日期对比DateTime object with isBefore函数?仅在Java Joda时间使用“isBefore”进行日期比较
对于离,
DateTime start = new DateTime(Long.parseLong(<someInput>));
DateTime end = new DateTime(Long.parseLong(<someInput>));
现在,当我这样做,
while (start.isBefore(end)) {
// add start date to the list
start = start.plusDays(1);
}
这导致不一致的行为(我的情况),因为它是考虑到时间以及而我想要的是使用isBefore比较日期。有没有办法可以做到这一点?
请让我知道。
谢谢!
感谢您的回复。我想将DateTime存储在循环中,所以不用将DateTime转换为LocalDate,然后将LocalDate转换回DateTime,我认为使用DateFormatter更好。 – test123 2012-03-07 22:10:33
只需确保您在进入/离开夏令时时不会有任何奇怪的行为!日期和时间往往比第一次出现时更复杂...... – 2012-03-07 22:16:24
我刚刚重新评估了我的应用程序的用例,并且看起来像使用LocalDate会更好。谢谢! – test123 2012-03-07 22:18:41