I want to create a DateTime object from ISO8601 String (e.g., 2012-11-05T07:00:00+0000). Here is the code:
...
DateTime day = new DateTime(dateStr);
System.out.println(dateStr + "=>" + day);
I got these results:
...
2012-11-04T07:00:00+0000=>2012-11-04T00:00:00.000-07:00
2012-11-05T07:00:00+0000=>2012-11-04T23:00:00.000-08:00
2012-11-06T08:00:00+0000=>2012-11-06T00:00:00.000-08:00
...
11-04 and 11-06 are correct, but 11-05 are wrong. How to fix it? I am on the west coast of North America.
In what way is 11-05 wrong? On November 4th at 2am local time (i.e. 9am UTC), west coast time went from UTC-7 to UTC-8.
Now November 5th at 7am UTC, which is your second line, is after that point in time, therefore it’s correct for it to be UTC-8… and therefore the local time is 11pm on November 4th, exactly as shown.
Joda Time is right here (unsurprisingly).