假设您可以按照Jon Skeet的建议计算"今天"的日期/时间范围:
LocalDate today = now.toLocalDate();
LocalDate tomorrow = today.plusDays(1);
DateTime startOfToday = today.toDateTimeAtStartOfDay(now.getZone());
DateTime startOfTomorrow = tomorrow.toDateTimeAtStartOfDay(now.getZone());
Then check if startOfToday <= time < startOfTomorrow for any particular time.
你会如何为"本周"做类似的事情。
因此,如果"今天"是2011年6月29日20:38,"本周"将是
20:38 22/06/2011 - 20:38 29/06/2011
DateTime startOfWeek = dateTime.minusDays(dateTime.dayOfWeek().get() - 1);
DateTime endOfWeek = dateTime.plusDays(7 - dateTime.dayOfWeek().get());
(注:周天数以1为基础)