Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • It fails to parse this date: 2015-08-11T13:10:00. I get String index out of range: 19. Looking at the code it seems that it requires the milliseconds to be specified, and the timezone. Those should be optional. Commented Aug 11, 2015 at 14:54
  • 3
    To quote the documentation, the parse format is: [yyyy-MM-dd|yyyyMMdd][T(hh:mm[:ss[.sss]]|hhmm[ss[.sss]])]?[Z|[+-]hh:mm]]. In other words, the milliseconds is optional but the timezone is mandatory. Commented Aug 12, 2015 at 9:23
  • 2
    Ah yes actually it looks like you are right. Still, I'm pretty sure ISO8601 allows you to omit the timezone so it's still wrong. JodaTime works though: new DateTime("2015-08-11T13:10:00").toDate() Commented Aug 12, 2015 at 10:56
  • 3
    That class is now deprecated, the new one is StdDateFormat. Otherwise it works the same. Commented Mar 14, 2018 at 13:59
  • ISO8601DateFormat is deprecated use StdDateFormat instead Commented Nov 13, 2020 at 10:27