4

In android How can I parse following DateTime ?

"2014-03-11T00:16:01.847" (iso 8061 format) Which is produced by NewtonSoft JsonConvert library

I have tried following format but did not succeed

"yyyy-MM-dd'T'HH:mm:ss.SS'Z'"

"YYYY-MM-DDThh:mm:ssTZD"
user2864740
  • 60,010
  • 15
  • 145
  • 220
crypted
  • 10,118
  • 3
  • 39
  • 52
  • [8601 surely?](http://en.wikipedia.org/wiki/ISO_8601) - Have a look [here](http://stackoverflow.com/questions/2201925/converting-iso8601-compliant-string-to-java-util-date) – StuartLC Mar 12 '14 at 06:08
  • I focused the title around *Gson* usage; if this is about parsing the/a DateTime *outside* of Gson, make sure to re-adjust the title (and remove the Gson tag). – user2864740 Mar 12 '14 at 06:13
  • @StuartLC yes it is. It is mentioned in their site as 'From Json.NET 4.5 and onwards dates are written using the ISO 8601 format by default and using this converter is unnecessary' http://james.newtonking.com/json/help/index.html?topic=html/DatesInJSON.htm – crypted Mar 12 '14 at 06:16

1 Answers1

1

ISO 8601 format: "yyyy-MM-dd'T'HH:mm:ssX"

Tema
  • 11
  • 1
  • That is not ISO 8601 compliant. HH is 0 - 23. It will fail at midnight. There will be various other issues too. See: https://en.wikipedia.org/wiki/ISO_8601 – Hakkar Mar 21 '15 at 00:57
  • If the above is incorrect, can someone please edit it to be correct? – jocull Aug 06 '18 at 14:17