diff --git a/excel-importer-test/src_test/com/axonivy/util/excel/test/TestExcelReader.java b/excel-importer-test/src_test/com/axonivy/util/excel/test/TestExcelReader.java index 665a18b..993c249 100644 --- a/excel-importer-test/src_test/com/axonivy/util/excel/test/TestExcelReader.java +++ b/excel-importer-test/src_test/com/axonivy/util/excel/test/TestExcelReader.java @@ -4,7 +4,7 @@ import java.io.IOException; import java.nio.file.Path; -import java.util.Date; +import java.sql.Timestamp; import java.util.List; import org.apache.poi.ss.usermodel.Workbook; @@ -27,7 +27,7 @@ void parseColumns_xlsx(@TempDir Path dir) throws IOException { .contains("Firstname", "Lastname"); assertThat(columns).contains( new Column("Firstname", String.class, 255), new Column("ZIP", Integer.class), - new Column("Amount", Double.class), new Column("Birthdate", Date.class), // should be a date + new Column("Amount", Double.class), new Column("Birthdate", Timestamp.class), // should be a date new Column("Note", String.class, 811) ); } diff --git a/excel-importer/src/com/axonivy/util/excel/importer/Column.java b/excel-importer/src/com/axonivy/util/excel/importer/Column.java index e28b32f..5409f75 100644 --- a/excel-importer/src/com/axonivy/util/excel/importer/Column.java +++ b/excel-importer/src/com/axonivy/util/excel/importer/Column.java @@ -48,10 +48,12 @@ public void setDatabaseFieldLength(Integer databaseFieldLength) { @Override public boolean equals(Object object) { - if (this == object) + if (this == object) { return true; - if (object == null || getClass() != object.getClass()) + } + if (object == null || getClass() != object.getClass()) { return false; + } Column column = (Column) object; diff --git a/excel-importer/src/com/axonivy/util/excel/importer/EntityDataLoader.java b/excel-importer/src/com/axonivy/util/excel/importer/EntityDataLoader.java index 5084dcf..a3c4528 100644 --- a/excel-importer/src/com/axonivy/util/excel/importer/EntityDataLoader.java +++ b/excel-importer/src/com/axonivy/util/excel/importer/EntityDataLoader.java @@ -4,6 +4,7 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; +import java.sql.Timestamp; import java.util.Iterator; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -131,7 +132,7 @@ private static Object getValue(Cell cell) { } if (cell.getCellType() == CellType.NUMERIC) { if (DateUtil.isCellDateFormatted(cell)) { - return cell.getDateCellValue(); + return new Timestamp(cell.getDateCellValue().getTime()); } return cell.getNumericCellValue(); } else if (cell.getCellType() == CellType.BOOLEAN) { diff --git a/excel-importer/src/com/axonivy/util/excel/importer/ExcelReader.java b/excel-importer/src/com/axonivy/util/excel/importer/ExcelReader.java index 1731870..7dbd622 100644 --- a/excel-importer/src/com/axonivy/util/excel/importer/ExcelReader.java +++ b/excel-importer/src/com/axonivy/util/excel/importer/ExcelReader.java @@ -1,7 +1,7 @@ package com.axonivy.util.excel.importer; +import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Date; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -62,7 +62,7 @@ private static Column toColumn(String fieldName, Cell cell) { switch (cell.getCellType()) { case NUMERIC: if (DateUtil.isCellDateFormatted(cell)) { - return new Column(fieldName, Date.class); + return new Column(fieldName, Timestamp.class); } if (CellUtils.isInteger(cell)) { return new Column(fieldName, Integer.class);