Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Joda-time: First day in this year's ISO week 1

Tags:

java

jodatime

I would like to find out the date of the Monday in this year's ISO week 1 (For 2009 this would be Monday, Dec 29 2008).

I'm sure that joda-time can handle this, but I just can't figure out the API (maybe it's just too late).

Can anyone help? Thanks!

like image 614
otto.poellath Avatar asked May 07 '09 17:05

otto.poellath


2 Answers

The DateMidnight API mentioned in the other answer is now deprecated, use below:

DateTime date = new DateTime().dayOfYear().withMinimumValue().withTimeAtStartOfDay();
like image 183
shaILU Avatar answered Sep 17 '22 14:09

shaILU


I believe this should work:

DateMidnight date = new DateMidnight().withWeekOfWeekyear(1).withDayOfWeek(1);
like image 28
Blake Pettersson Avatar answered Sep 18 '22 14:09

Blake Pettersson