@@ -1608,6 +1608,47 @@ public void copyToSXSSF() throws Exception {
16081608 }
16091609 }
16101610
1611+ @ Test
1612+ public void copyToSXSSFFormattedDate () throws Exception {
1613+ try (
1614+ InputStream inputStream = new FileInputStream ("src/test/resources/formatted-date.xlsx" );
1615+ UnsynchronizedByteArrayOutputStream bos = UnsynchronizedByteArrayOutputStream .builder ().get ()
1616+ ) {
1617+ // since POI 5.3.0, you no longer need to call dispose() on SXSSFWorkbook
1618+ try (SXSSFWorkbook wbOutput = CopyToSXSSFUtil .copyToSXSSF (inputStream )) {
1619+ wbOutput .write (bos );
1620+ }
1621+
1622+ try (XSSFWorkbook xssfWorkbook = new XSSFWorkbook (bos .toInputStream ())) {
1623+ DataFormatter formatter = new DataFormatter ();
1624+
1625+ Sheet sheet = xssfWorkbook .getSheet ("Sheet0" );
1626+ Iterator <Row > rowIterator = sheet .rowIterator ();
1627+
1628+ assertTrue (rowIterator .hasNext ());
1629+ // header
1630+ Row currentRow = rowIterator .next ();
1631+ assertTrue (rowIterator .hasNext ());
1632+ currentRow = rowIterator .next ();
1633+
1634+ List <String > expected = Arrays .asList (
1635+ "10002" , "John" , "Doe" , "06 September 1976" , "1" , "NORMAL" , "NORMAL" , "CUSTOMER" , "Customer" ,
1636+ "NOT_CONFIRMED" , "94" , "2" , "FALSE()"
1637+ );
1638+
1639+ for (int i = 0 ; i < currentRow .getLastCellNum (); i ++) {
1640+ Cell cell = currentRow .getCell (i , Row .MissingCellPolicy .CREATE_NULL_AS_BLANK );
1641+
1642+ String value = formatter .formatCellValue (cell );
1643+
1644+ assertEquals (expected .get (i ), value );
1645+ }
1646+
1647+ assertEquals ("1976-09-06T00:00" , currentRow .getCell (3 ).getLocalDateTimeCellValue ().toString ());
1648+ }
1649+ }
1650+ }
1651+
16111652 @ Test
16121653 public void copyToSXSSFWithHyperlinks () throws Exception {
16131654 ArrayList <String > originalLocations = new ArrayList <>();
0 commit comments