Fesod version
Current main at 5a9a16b.
Description
Default string-to-date conversion is lenient. Invalid calendar dates are silently changed into different valid dates instead of failing conversion.
Location
fesod-sheet/src/main/java/org/apache/fesod/sheet/util/DateUtils.java:378-395
fesod-sheet/src/main/java/org/apache/fesod/sheet/util/DateUtils.java:398-411
SimpleDateFormat keeps its default lenient behavior. DateTimeFormatter.ofPattern uses SMART resolver behavior unless made strict.
Reproduction
DateUtils.parseDate("2024-02-31");
// formats back as 2024-03-02
DateUtils.parseLocalDate("2024-02-31", null, Locale.US);
// returns 2024-02-29
A valid control value such as 2024-02-29 remains unchanged.
Expected behavior
Invalid calendar dates should raise a conversion error. Importing malformed spreadsheet text must not silently change the represented date.
Suggested fix
Disable lenient SimpleDateFormat parsing and use strict resolver semantics for java.time parsing. Account for yyyy versus uuuu when making existing patterns strict, and add converter-level regression tests for invalid month-end and leap-day values.
Related existing work
#1116/#1117 cover negative Excel serial dates. #1040 covers locale handling. Neither covers invalid string dates being normalized.
Are you willing to submit a PR?
Yes.
Fesod version
Current
mainat5a9a16b.Description
Default string-to-date conversion is lenient. Invalid calendar dates are silently changed into different valid dates instead of failing conversion.
Location
fesod-sheet/src/main/java/org/apache/fesod/sheet/util/DateUtils.java:378-395fesod-sheet/src/main/java/org/apache/fesod/sheet/util/DateUtils.java:398-411SimpleDateFormatkeeps its default lenient behavior.DateTimeFormatter.ofPatternuses SMART resolver behavior unless made strict.Reproduction
A valid control value such as
2024-02-29remains unchanged.Expected behavior
Invalid calendar dates should raise a conversion error. Importing malformed spreadsheet text must not silently change the represented date.
Suggested fix
Disable lenient
SimpleDateFormatparsing and use strict resolver semantics for java.time parsing. Account foryyyyversusuuuuwhen making existing patterns strict, and add converter-level regression tests for invalid month-end and leap-day values.Related existing work
#1116/#1117 cover negative Excel serial dates. #1040 covers locale handling. Neither covers invalid string dates being normalized.
Are you willing to submit a PR?
Yes.