Skip to content

Commit

Permalink
add datetime test
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1923881 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
pjfanning committed Feb 17, 2025
1 parent dbaf834 commit 5b12033
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,22 @@ void setCellFormulaWithDateArithmetic() throws IOException {
}
}

@Test
void testZeroDate() throws IOException {
try (Workbook wb = _testDataProvider.createWorkbook()) {
Cell cellA1 = getInstance(wb);
cellA1.setCellValue(1.0);
assertEquals(LocalDate.parse("1900-01-01"),
cellA1.getLocalDateTimeCellValue().toLocalDate());

cellA1.setCellValue(0.0);
// this value is not strictly correct but our time only support relies on this
// time only means cells that have values with just times but no date parts
assertEquals(LocalDate.parse("1899-12-31"),
cellA1.getLocalDateTimeCellValue().toLocalDate());
}
}

@Test
protected void setCellType_FORMULA_onAnArrayFormulaCell_doesNothing() throws IOException {
try (Workbook wb = _testDataProvider.createWorkbook()) {
Expand Down

0 comments on commit 5b12033

Please sign in to comment.