LocalDateTime parsen

Hi,

ich habe folgende Zeit als String 2017-01-27T11:10:38+0100, welchen ich ihn ein LocalDateTime Objekt bringen will.

Laut Javadoc, sollte das mit

LocalDateTime.parse("2017-01-27T11:10:38+0100", DateTimeFormatter.ISO_DATE_TIME)

, da DateTimeFormatter.ISO_DATE_TIME laut doc "The ISO-like date-time formatter that formats or parses a date-time with the offset and zone if available, such as ‘2011-12-03T10:15:30’, ‘2011-12-03T10:15:30+01:00’ or ‘2011-12-03T10:15:30+01:00[Europe/Paris]’.

Lass ich den Code aber bei mir laufen, fliegt eine RuntimeException

Exception in thread "main" java.time.format.DateTimeParseException: Text '2017-01-27T11:10:38+0100' could not be parsed at index 19
	at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1947)
	at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1849)
	at java.time.LocalDateTime.parse(LocalDateTime.java:492)
	at test.TestClass.main(TestClass.java:14)

was übersehe ich ?

den Doppelpunkt

Hm… ist das wirklich ISO Format ohne den Doppelpunkt zwischen Stunden und Minuten?

Ist der String so richtig den du als Beispiel nimmst?

ich bekomme den wert von der Sonarqube web api

laut docu steht da auch

Example value
2013-05-01T13:00:00+0100

Aha…

Converting ISO 8601-compliant String to java.util.Date - Stack Overflow

„missing colon“ in der Google Suche half :wink:
(aber „schoen“ ist anders)

Relevanter XKCD: xkcd: Standards