You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2020/01/02 14:58:30 UTC

svn commit: r1872246 - in /poi/trunk/src: java/org/apache/poi/ss/usermodel/Cell.java testcases/org/apache/poi/ss/usermodel/BaseTestCell.java

Author: fanningpj
Date: Thu Jan  2 14:58:30 2020
New Revision: 1872246

URL: http://svn.apache.org/viewvc?rev=1872246&view=rev
Log:
[bug-64044] setCellValue(LocalDate) does not support nulls properly

Modified:
    poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java?rev=1872246&r1=1872245&r2=1872246&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/Cell.java Thu Jan  2 14:58:30 2020
@@ -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());
     }
 
     /**

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java?rev=1872246&r1=1872245&r2=1872246&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java Thu Jan  2 14:58:30 2020
@@ -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());



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org