How can I parse this code to localDateTime?
I have 2 area that give me localDateTime, One of them is 2023-02-22T09:47:00.5371934+03:00 the other one is 2023-02-22T09:47:00.537 and response like this:
java.time.format.DateTimeParseException: Text '2023-02-22T09:47:00.537' could not be parsed at index 23 \n\tat org.apache.cxf.jaxws.JaxWsClientProxy.mapException(JaxWsClientProxy.java:195)
I have tried DateTimeFormatter.ISO_ZONED_DATE_TIME, it didn't work.
Do u you have any suggestions?
OffsetDateTime
Your first input has an offset of three hours ahead of UTC. So parse as an OffsetDateTime
.
OffsetDateTime odt = OffsetDateTime.parse( "2023-02-22T09:47:00.5371934+03:00" ) ;
LocalDateTime
This other input has no offset, and no time zone. So parse as a LocalDateTime
.
LocalDateTime ldt = LocalDateTime.parse( "2023-02-22T09:47:00.537" ) ;