Why can I parse a date time string in java with an invalid hour? What have I missed or need to do to ensure that it throws an error appropriately.
The following code does not throw an error, where it should?
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss");
LocalDateTime aFormattedDate = LocalDateTime.parse("2019-01-01T24:00:00", dateTimeFormatter); // returns 2019-01-02T00:00:00, should throw an error
Specifying the hour as 25, or including any millisecond or other time component does cause parse
to throw an error.
Where as
LocalDateTime aDate = LocalDateTime.parse("2019-01-01T24:00:00"); //throws an error
Does throw an error - about HourOfDay needs to be between 0 and 23 - as expected