-1

I want to parse a timestamp into a OffsetDateTime represented as following:

2019-08-02T30:17:48.128+0200

Note that there is no : between the hours and minutes in the offset notation, as expected by OffsetDateTime.

When feeding this to OffsetDateTime.parse("2019-08-02T30:17:48.128+0200"), I get a java.time.format.DateTimeParseException.

Akke
  • 1
  • 1

1 Answers1

0

Create a DateTimeFormatter with ZZZ for the time zone offset.

DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZZZ");
OffsetDateTime.parse("2019-08-02T10:17:48.128+0200", dtf);

Also, the hour in the example is not correct: 30 is not a valid value.

areus
  • 2,880
  • 2
  • 7
  • 17