From 42d86f6fe741877fc5c5bdf3d62f4b16f29354de Mon Sep 17 00:00:00 2001 From: nntthuy-axonivy Date: Thu, 12 Dec 2024 14:15:56 +0700 Subject: [PATCH] Change Timestamp to Date --- .../util/excel/test/TestExcelReader.java | 15 +++++++++++++-- .../util/excel/test/sample_date_format.xlsx | Bin 0 -> 11816 bytes .../util/excel/importer/ExcelReader.java | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 excel-importer-test/src_test/com/axonivy/util/excel/test/sample_date_format.xlsx 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 1d6fe91..16d669f 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.sql.Timestamp; +import java.util.Date; import java.util.List; import org.apache.poi.ss.usermodel.Workbook; import org.junit.jupiter.api.Test; @@ -25,7 +25,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", Timestamp.class), // should be a date + new Column("Amount", Double.class), new Column("Birthdate", Date.class), // should be a date new Column("Note", String.class, 811), new Column("Column contains texts in incorrect number format", String.class, 255), new Column("Column contains both text and numeric", String.class, 255) @@ -44,4 +44,15 @@ void parseColumnsOver255Characters_xlsx(@TempDir Path dir) throws IOException { new Column("Summary", String.class, 823)); } + @Test + void parseColumnsSeveralDateFormats_xlsx(@TempDir Path dir) throws IOException { + Path path = dir.resolve("customers.xlsx"); + TstRes.loadTo(path, "sample_date_format.xlsx"); + Workbook wb = ExcelLoader.load(path); + List columns = ExcelReader.parseColumns(wb.getSheetAt(0)); + assertThat(columns).extracting(Column::getName).contains("Start date", "End date", "Date without year"); + assertThat(columns).contains(new Column("Start date", Date.class), + new Column("End date", Date.class), new Column("Date without year", Date.class)); + } + } diff --git a/excel-importer-test/src_test/com/axonivy/util/excel/test/sample_date_format.xlsx b/excel-importer-test/src_test/com/axonivy/util/excel/test/sample_date_format.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..fed09ecac2b1e03246d4bea8d184e184cd249000 GIT binary patch literal 11816 zcmd^l1yo#Fvu@)a8bSyJmteu2;O_3hrEzG2y95gf65KsNf(HohB)AjYH4wb9;I|3$ z&t&q?oj3R1_tv^=y|WhGy=#9}wRfF;YEj=QC0RIlRKV>OqOdG<`~9yA1^UAjY@*}< zws&Mwg2Hg10^}bsU3Q5F+%N!u5G()y{269sZ_nsvYm*k$D)WgM7`*pl59nY}QU9`Q z#0*QUL3^^`>!d=pKPO7khwXEEeLiG;K2OMMAKKGRFo5R7=7}Huyf^mOI zTlpSyB-McyoT@KoX^`Ga8;3spXx3b-BL7%0%$dsW-s7a|dwiBcxa8=04O9+jWM%KN z)ZKul_hWm`HI%iko=p~vAf!$&S0RWR3#1XFOac?JdqOYnt+G5H9`+TL)j9HViv#Nc z;=4l~!x?dc;vr9UKExen$`rvM-)GT?IV24{Ng5#rjSOc8yeKk%w4n};W-a|2%^(KMycf&I_&E7LC(V%Fg9#ufMKD;Yhqo z_IuOCoU7~S%gn8f`>C4Yw9@f!DPbudz3;1{EG-oGk|d9umD1-zlo|1-KKyoG0E`dq zXsxiO=T=+H5n@e8(TOI?2E}@Ofa~|hCZu|q(qS2~v{m)R;h?oz=#V{48Kdj5q(WrN zWP}(iX)a!r%icF)QiPyK?084)vaIJj;`Y-w+CxtsDioJh80C@eKGt~^!(E4|AKp=A z8{;z4iG0R(UghPnDH$HevnvC5A93-%wiBeaCgI<(M`r?by(r0S&J}qjKzRQi_lqzQ zUKdnXjq#X}&aoG2?#YTP^qAnd`Er}KyiHHx!IG?|NB$lgHzdpb+b`S@)x38zs7spw ze-5t`CG+SLXn3)p;l2N-@H#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