获取正确范围内的 DateTime 倒数 - Joda Time
我想得到日期时间的计数,该计数与乔达时间在正确的范围内。 我现在有这个版本,它只适合检查特定的一天:
public int getIntFatalitiesAtDay(DateTime AtDay) {
int resultCount = 0;
for( Fatality f : fatalities) {
if(Days.daysBetween(f.date, AtDay).getDays() == 0) {
resultCount++;
}
}
return resultCount;
}
当我每天循环抛出时,这很有用。但是现在我按月计算:
for (DateTime iDate = fa.firstDate; iDate.isBefore(fa.lastDate); iDate = iDate.plusMonths(1)) { ... }
现在我想了解该月的死亡人数。 有人可以帮忙吗?
(也是从那一年开始,虽然我也希望看到一个不考虑年份的选项,但这不太重要。)
I want to get the count back of DateTime that where within the correct range with Joda Time.
I have this version at the moment which is only good to check for a specific day:
public int getIntFatalitiesAtDay(DateTime AtDay) {
int resultCount = 0;
for( Fatality f : fatalities) {
if(Days.daysBetween(f.date, AtDay).getDays() == 0) {
resultCount++;
}
}
return resultCount;
}
This was usefull when i looped threw every day. However now i go by months with:
for (DateTime iDate = fa.firstDate; iDate.isBefore(fa.lastDate); iDate = iDate.plusMonths(1)) { ... }
And now i would like to get the count of fatalities that month.
Could someone help?
(Also from that year, althought i would like to see a option aswell where it doesn't look at the year but that's less important.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Java 的 java.util.Date 类具有用于确定一个日期是在另一个日期之前还是之后的方法。如果将 DateTime 对象转换为 Date 对象,您可以执行以下操作:
Java's
java.util.Date
class has methods for determining if one date is before or after another. If you convert the DateTime objects to Date objects, you can do: