I am having a hard time converting an ISO 8601 formatted String to a java.time.LocalDateTime which is in UTC.
More specific, I am trying to write an XMLAdapter for which you can enter the various ISO 8601 dataformats as a String (i.e. 2002-09-24, 2011-03-22T13:30, 2015-05-24T12:25:15Z, 2015-07-28T11:11:15.321+05:30) and which outputs a LocalDateTime in UTC and visa versa.
The system stores all it's Date and Time information internal in UTC times. When a user requests a Date or Time it is represented to the user based on their own ZoneId.
Edit: Basils answer below should be marked correct. https://stackoverflow.com/a/43083698/348956
As the name suggests
LocalDateTimeholds both Date and Time. The first example of a date string you have in your question for example only holds information about the date, therefore you cannot parse this directly into aLocalDateTime. What you could do there is to first parse it into aLocalDateand by setting the time on that object get aLocalDateTime.All Date and Time objects have a parse method like
LocalDatewhich can take a certain string format. These formats are different ISO standard formats specified in DateTimeFormatterFor formatting custom datetime strings into
Temporalobjects use DateTimeFormatter and specify a custom pattern.