Skip to content

Commit

Permalink
Fix wrong time in output CSV reporting data
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisszmundy committed Sep 23, 2024
1 parent 919ef6e commit 6b386e4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")));

}

Expand Down

0 comments on commit 6b386e4

Please sign in to comment.