Java – how to parse joda time in this format
•
Java
I convert the datestring of yyyy MM DD HH: mm: SS in JSON format into the code and save it to POJO
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); this.startDate = format.parseDateTime(startDate);
When I convert POJO back to JSON, the date is written as 2013-07-12t18:31:01.000z How do we parse the time string 2013-07-12t18:31:01.000z back to the jodadatetime object What is formatting? I use yyyy MM DD HH: mm: SS, it doesn't work
Solution
2013-07-12 t18:31:01.000z it is the standard ISO date format
String startDate = "2013-07-12T18:31:01.000Z"; DateTime dt = ISODateTimeFormat.dateTime().parseDateTime(startDate);
In this case, the date will be converted to the date in your time zone If you want to ignore your time zone in the formatter and use the UTC zone:
String startDate = "2013-07-12T18:31:01.000Z"; DateTime dt = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC).parseDateTime(startDate);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码