1

I'm trying to parse 2014-11-28T13:46:23-08:00 to a java.util.Date

For the simpledateformat so far I've tried:

yyyy-MM-dd'T'HH:mm:ss
yyyy-MM-dd HH:mm:ss

yyyy-MM-dd works but I need at-least precision to the minute.

What pattern should I be using to parse this date?

Nerdroid
  • 13,398
  • 5
  • 58
  • 69
Derek
  • 632
  • 2
  • 11
  • 29

1 Answers1

4

This looks like the standard ISO-8601 date format. Try:

yyyy-MM-dd'T'HH:mm:ssZ

This is very close to the first format you tried, with the addition of "Z". That character is for the UTC offset.

EJK
  • 12,332
  • 3
  • 38
  • 55
  • 1
    According to the description it should IMO be `yyyy-MM-dd'T'HH:mm:ssXXX` - `Z` is for `-0800`, while `XXX` is for `-08:00`. See examples at the end of the [`SimpleDateFormat` docs](http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html) EDIT: `X` is apparently a Java7+ thing http://stackoverflow.com/a/10614978/995891 – zapl Dec 04 '14 at 23:55