Issue
I am working with jira
api and in one of request I get the response with date field in format like this: 2022-10-26T09:34:00.000+0000
. I need to convert this to LocalDate
but I do not know how to to this with this strange format.
Here are some of formats I already tried:
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS")
DateTimeFormatter.ISO_LOCAL_DATE_TIME
but both cannot deserialize this +
sign at the end of the date.
Text '2022-10-27T09:34:00.000+0000' could not be parsed, unparsed text found at index 24
Solution
You have to add the timezone:
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
Checkout the documentation https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
Answered By - Simon Martinelli
Answer Checked By - Gilberto Lyons (JavaFixing Admin)