How do you get the date/time range for “this week” using the Joda date/time library in Java?
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
Assuming you can calculate the date/time range for "today" by following Jon Skeet's advice:
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.
How would you do something similar for "this week".
So, if "today" is 20:38 29/06/2011, "this week" would be
20:38 22/06/2011 - 20:38 29/06/2011
This question and answers originated from www.stackoverflow.com
Question by Morris (6/29/2011 7:40:39 PM)
Answer |