How may I get week start timestamp (2010-03-01 00:00:00 UTC) and week end timestamp (2010-03-08 00:00:00 UTC) given a java.util.Date (or Joda DateTime), or year and ISO week number, using Java SE API and Joda Time?
views:
249answers:
1
A:
JodaTime has support for ISO week numbers (see here). For example:
java.util.Date date = new java.util.Date();
DateTime dateTime = new DateTime(date);
int isoWeek = dateTime.getWeekOfWeekyear();
You can also set the "start of aweek" using something like this:
DateTime startOfWeek = dateTime.withWeekOfWeekyear(4).withDayOfWeek(1).withTime(0, 0, 0, 0);
skaffman
2010-03-03 23:28:39