-1

My code is:

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm");
String filterValue = "01.03.2021 0:01";
LocalDateTime parsedDate = LocalDateTime.parse(filterValue, formatter);

I get the exception java.time.format.DateTimeParseException: Text '01.03.2021 0:01' could not be parsed at index 11

Jens Kisters
  • 117
  • 2
  • 10

1 Answers1

1

The format says "HH" but the value provided is "0". "01.03.2021 00:01" works.

I think its pretty unpractical to force a leading zero for the hour but well, i got a solution.

Jens Kisters
  • 117
  • 2
  • 10