Aias00 opened a new pull request, #974:
URL: https://github.com/apache/fesod/pull/974

   ## 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`:
   
   ```java
   @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
   
   ```java
   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`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to