How to calculate Date from ISO8601 week number in Java

UPDATE: The concepts presented here still apply, but the code is outmoded. The Joda-Time project, now in maintenance mode, advises migration to the java.time classes. See the java.time code in the Answer by Szulc. Short Answer DateTime dateTimeStart = new DateTime( “2003-W01-1”, DateTimeZone.UTC ); // Joda-Time 2.4. DateTime dateTimeStop = dateTimeStart.plusWeeks( 1 ); For details, … Read more

Week number of the month?

In order to use straight division, the day of month for the date you’re looking at needs to be adjusted according to the position (within the week) of the first day of the month. So, if your month happens to start on a Monday (the first day of the week), you can just do division … Read more

How to get week numbers from dates?

Base package Using the function strftime passing the argument %V to obtain the week of the year as decimal number (01–53) as defined in ISO 8601. (More details in the documentarion: ?strftime) strftime(c(“2014-03-16”, “2014-03-17″,”2014-03-18”, “2014-01-01”), format = “%V”) Output: [1] “11” “12” “12” “01”

Calculate date from week number

I had issues with the solution by @HenkHolterman even with the fix by @RobinAndersson. Reading up on the ISO 8601 standard resolves the issue nicely. Use the first Thursday as the target and not Monday. The code below will work for Week 53 of 2009 as well. public static DateTime FirstDateOfWeekISO8601(int year, int weekOfYear) { … Read more