1
DateTime time=DateTimeFormat.forPattern("yyyy-ww").parseDateTime("2013-01"); 

where DateTimeFormat is org.joda.time.format.DateTimeFormat.

When I execute the above, time becomes 2013-12-30T00:00:00.000 what am I doing wrong? Is this a bug? I expect it to be the first week of 2013, not the last.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
Tony Wolff
  • 732
  • 1
  • 10
  • 23

1 Answers1

3

See here.

The w, week of weekyear, pattern letter is meant to be used with x, weekyear. From the javadoc of DateTimeFormat

 x       weekyear                     year          1996
 w       week of weekyear             number        27

Change your pattern to

DateTimeFormat.forPattern("xxxx-ww")

and you'll parse to

2012-12-31T00:00:00.000-08:00

Depending on your Locale, the first week of 2013 started in 2012.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724