Skip to content

fix: mark CsvCell Calendar value as a date to avoid silent empty write - #974

Open
Aias00 wants to merge 1 commit into
apache:mainfrom
Aias00:fix/csv-cell-calendar-date
Open

fix: mark CsvCell Calendar value as a date to avoid silent empty write#974
Aias00 wants to merge 1 commit into
apache:mainfrom
Aias00:fix/csv-cell-calendar-date

Conversation

@Aias00

@Aias00 Aias00 commented Jul 27, 2026

Copy link
Copy Markdown

Summary

Fixes #973.

CsvCell.setCellValueImpl(Calendar) set cellType = NUMERIC but did not set numericCellType = NumericCellTypeEnum.DATE, so CsvSheet.buildCellValue took the number branch, found numberValue was null, and wrote an empty field — silently dropping the Calendar value. The sibling Date and LocalDateTime setters already set the date type.

Root cause

CsvCell:

@Override
protected void setCellValueImpl(Calendar value) {
    if (value == null) {
        return;
    }
    this.dateValue = LocalDateTime.ofInstant(value.toInstant(), ZoneId.systemDefault());
    this.cellType = CellType.NUMERIC;
    // missing: this.numericCellType = NumericCellTypeEnum.DATE;
}

CsvSheet.buildCellValue dispatches on csvCell.getNumericCellType() == NumericCellTypeEnum.DATE; without it the cell falls through to the number branch, where numberValue is null, and returns null → empty field.

Fix

this.numericCellType = NumericCellTypeEnum.DATE;

Verification

Added CsvRowTest.csvWrite_withCalendar_producesCorrectFile: writes a Calendar (2024-01-15 12:30:45) to a CsvCell via the POI Cell API and reads the CSV file back. Before the fix the cell was an empty field; after the fix the line contains 2024-01-15. Full fesod-sheet suite: Tests run: 668, Failures: 0.

apache#973)

setCellValueImpl(Calendar) set cellType=NUMERIC but did not set
numericCellType=DATE, so CsvSheet.buildCellValue took the number branch,
found numberValue null, and wrote an empty field - silently dropping the
Calendar value. Mirrors the Date and LocalDateTime setters. Add an
integration test that writes a Calendar and reads the CSV back.
Copilot AI review requested due to automatic review settings July 27, 2026 15:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] CsvCell.setCellValue(Calendar) silently writes an empty field

2 participants