Repository navigation
Conversation
4666300 to
872b3af
Compare
872b3af to
3123b5c
Compare
| LocalDate date = DateUtils.getLocalDate( | ||
| cellData.getNumberValue().doubleValue(), | ||
| DateUtils.isDate1904(contentProperty, globalConfiguration)); |
There was a problem hiding this comment.
Suggest using DateUtils.getLocalDateTime() directly here.
getLocalDate() internally delegates to getLocalDateTime() and creates an unnecessary intermediate LocalDate object via toLocalDate(). Skipping it avoids redundant object allocation during parsing.
There was a problem hiding this comment.
Good point — switched to getLocalDateTime() in 8e3f6847. Thanks!
|
Hi @bengbengbalabalabeng — gentle follow-up on this one. All three inline points from your review are addressed: the redundant comments were removed in CI is 9/9 green and the PR is mergeable. Is there anything else you'd like changed? |
Purpose of the pull request
Related: #1017 (java.time.Year number converter slice). Background and evidence: #1216. A
java.time.Yearfield fails on read when the cell is numeric:The
Yearconverters added in #1087 only shipYearStringConverter, so the(Year, NUMBER)key is unmapped — while the sibling date-like types (LocalDate,LocalTime,java.util.Date) each ship a number converter. Numeric year columns are a common shape, so the read aborts on the first such cell; date-formatted cells fail the same way, as they are NUMBER cells at read time.What's changed?
YearNumberConverter, registered withputAllConverternext toYearStringConverter:2026→Year.of(2026)); a serial reading would give 1905, which is not what a year column means;NumberUtils.toIntlike the other number converters (truncates toward zero, throws instead of wrapping).Year→ the Excel serial of Jan 1 (DateUtil.getExcelDate(value.atDay(1), isDate1904)).YearNumberConverterTest(unit) plusYearNumberCellReadTest, which reads a POI-built file end to end.Verification
YearNumberCellReadTestfails with the exact reported symptom (Converter not found, convert NUMBER to java.time.Year).YearNumberConverterTest7/7 andYearNumberCellReadTest1/1.mvn clean package -Dmaven.test.skip=false -pl fesod-common,fesod-shaded,fesod-sheet→ 60 + 1055 tests, 0 failures (baseline 1047 + the 8 new).spotless:checkclean.Notes
(Year, null)key and CSV the(Year, STRING)key, both held byYearStringConverter, so fesod-written files keep producing STRING cells.