-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
19
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Java 19, Windows 11
A DESCRIPTION OF THE PROBLEM :
LocalDate.parse: Invalid dateStrings for example 2/30/2023 should not return a LocalDate.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
@Test
void invalidDateStringShouldThrowException() {
final var formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
assertThrows(DateTimeParseException.class, () -> LocalDate.parse("30.02.2023", formatter));
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
DateTimeParseException should be thrown
ACTUAL -
LocalDate.of(2023,2,28) is returned.
---------- BEGIN SOURCE ----------
@Test
void invalidDateStringShouldThrowException() {
final var formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
// should not return 2/28/2023
assertThrows(DateTimeParseException.class, () -> LocalDate.parse("30.02.2023", formatter));
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
not use it, write your own method.
Java 19, Windows 11
A DESCRIPTION OF THE PROBLEM :
LocalDate.parse: Invalid dateStrings for example 2/30/2023 should not return a LocalDate.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
@Test
void invalidDateStringShouldThrowException() {
final var formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
assertThrows(DateTimeParseException.class, () -> LocalDate.parse("30.02.2023", formatter));
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
DateTimeParseException should be thrown
ACTUAL -
LocalDate.of(2023,2,28) is returned.
---------- BEGIN SOURCE ----------
@Test
void invalidDateStringShouldThrowException() {
final var formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
// should not return 2/28/2023
assertThrows(DateTimeParseException.class, () -> LocalDate.parse("30.02.2023", formatter));
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
not use it, write your own method.