有没有一种方法可以使用isBefore函数将DateTime对象的日期进行比较?
例如
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比较日期。有办法吗?
请告诉我。
谢谢!
如果您只想比较日期,则可能要使用LocalDate
类,而不是DateTime
。
JodaTime文档非常不错:http ://joda-time.sourceforge.net/apidocs/org/joda/time/LocalDate.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句