diff --git a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/extradata/reportingdata/CSVReportingDataParser.java b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/extradata/reportingdata/CSVReportingDataParser.java index 086f9575..353d3557 100644 --- a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/extradata/reportingdata/CSVReportingDataParser.java +++ b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/extradata/reportingdata/CSVReportingDataParser.java @@ -81,7 +81,7 @@ public long convertToTimestamp(String rowTimestamp) { log.error("Parsing error : the parsed date is null"); return 0L; } - return TimeUnit.MILLISECONDS.toSeconds(parsedDate.getTime()); + return parsedDate.getTime(); } /** diff --git a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/extradata/reportingdata/ReportingDataParser.java b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/extradata/reportingdata/ReportingDataParser.java index 1bdf5387..18376a4f 100644 --- a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/extradata/reportingdata/ReportingDataParser.java +++ b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/extradata/reportingdata/ReportingDataParser.java @@ -10,7 +10,7 @@ import fr.insee.kraftwerk.core.utils.files.FileUtilsInterface; import lombok.extern.log4j.Log4j2; -import java.sql.Date; +import java.util.Date; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; diff --git a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/utils/DateUtils.java b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/utils/DateUtils.java index 95bdea3a..ee6840b4 100644 --- a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/utils/DateUtils.java +++ b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/utils/DateUtils.java @@ -32,6 +32,6 @@ public static long convertToTimestamp(String rowTimestamp, SimpleDateFormat date log.error("Parsing error : {}", e1.getMessage()); return 0L; } - return TimeUnit.MILLISECONDS.toSeconds(parsedDate.getTime()); + return parsedDate.getTime(); } } diff --git a/kraftwerk-core/src/test/java/fr/insee/kraftwerk/core/utils/DateUtilsTest.java b/kraftwerk-core/src/test/java/fr/insee/kraftwerk/core/utils/DateUtilsTest.java index 3a778bf9..f2b43891 100644 --- a/kraftwerk-core/src/test/java/fr/insee/kraftwerk/core/utils/DateUtilsTest.java +++ b/kraftwerk-core/src/test/java/fr/insee/kraftwerk/core/utils/DateUtilsTest.java @@ -10,10 +10,12 @@ class DateUtilsTest { @Test void convertDateTest() { - assertEquals(1645007098, DateUtils.convertToTimestamp("16/02/2022 11:24:58", new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"))); - assertEquals(1566544132, DateUtils.convertToTimestamp("23/08/2019 09:08:52", new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"))); - assertEquals(1111111111, DateUtils.convertToTimestamp("18/03/2005 02:58:31", new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"))); - assertEquals(1, DateUtils.convertToTimestamp("01/01/1970 01:00:01", new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"))); + assertEquals(1645007098000L, DateUtils.convertToTimestamp("16/02/2022 11:24:58", new SimpleDateFormat("dd/MM" + + "/yyyy HH:mm:ss"))); + assertEquals(1566544132000L, DateUtils.convertToTimestamp("23/08/2019 09:08:52", new SimpleDateFormat("dd/MM" + + "/yyyy HH:mm:ss"))); + assertEquals(1111111111000L, DateUtils.convertToTimestamp("18/03/2005 02:58:31", new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"))); + assertEquals(1000L, DateUtils.convertToTimestamp("01/01/1970 01:00:01", new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"))); }