diff options
author | PJ Fanning <fanningpj@apache.org> | 2020-01-02 14:58:30 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2020-01-02 14:58:30 +0000 |
commit | 5ec079072a101f21bbf6af72c7755f5f59413969 (patch) | |
tree | ef1a879ab72490ece066361c905463c27cf6ec38 /src | |
parent | adb8424bc1a1c9a502d2cd07757615b711d32c50 (diff) | |
download | poi-5ec079072a101f21bbf6af72c7755f5f59413969.tar.gz poi-5ec079072a101f21bbf6af72c7755f5f59413969.zip |
[bug-64044] setCellValue(LocalDate) does not support nulls properly
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1872246 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/poi/ss/usermodel/Cell.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/java/org/apache/poi/ss/usermodel/Cell.java b/src/java/org/apache/poi/ss/usermodel/Cell.java index 5f8f2fe418..ad26ed0882 100644 --- a/src/java/org/apache/poi/ss/usermodel/Cell.java +++ b/src/java/org/apache/poi/ss/usermodel/Cell.java @@ -210,7 +210,7 @@ public interface Cell { * will change the cell to a numerics cell and set its value. */ default void setCellValue(LocalDate value) { - setCellValue(value.atStartOfDay()); + setCellValue(value == null ? null : value.atStartOfDay()); } /** diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java index 89c4796de7..204ec9504a 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java @@ -133,6 +133,21 @@ public abstract class BaseTestCell { assertProhibitedValueAccess(cell, CellType.BOOLEAN, CellType.STRING, CellType.FORMULA, CellType.ERROR); + String strNull = null; + cell.setCellValue(strNull); + assertNull(cell.getRichStringCellValue()); + assertEquals(CellType.BLANK, cell.getCellType()); + + LocalDate ldNull = null; + cell.setCellValue(ldNull); + assertNull(cell.getLocalDateTimeCellValue()); + assertEquals(CellType.BLANK, cell.getCellType()); + + LocalDateTime ldtNull = null; + cell.setCellValue(ldtNull); + assertNull(cell.getLocalDateTimeCellValue()); + assertEquals(CellType.BLANK, cell.getCellType()); + cell.setCellErrorValue(FormulaError.NA.getCode()); assertEquals(FormulaError.NA.getCode(), cell.getErrorCellValue()); assertEquals(CellType.ERROR, cell.getCellType()); |