How to parse Joda time of this format

jackson, java, jodatime

Solution

`2013-07-12T18:31:01.000Z` it is standart ISO date time format. You can use standart Joda date time formatter ISODateTimeFormat::dateTime() Example:

  String startDate = "2013-07-12T18:31:01.000Z";
  DateTime dt = ISODateTimeFormat.dateTime().parseDateTime(startDate);  

in this case date will be converted to date in your time zone. If you want ignore your time zone use `UTC` zone in formatter:

  String startDate = "2013-07-12T18:31:01.000Z";
  DateTime dt = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC).parseDateTime(startDate);

Problem

I converted DateString of format `YYYY-mm-DD HH:MM:SS` in my JSON and persisted to POJO using the code ``` DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); this.startDate = format.parseDateTime(startDate); ``` When I convert the POJO back to JSON, the date is written like `2013-07-12T18:31:01.000Z`. How do we parse the time string `2013-07-12T18:31:01.000Z` back to JodaDateTime object. What should be the formatter. I used `YYYY-mm-DD HH:MM:SS` and it didn't work

Original source