Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import java.sql.Date;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

Expand Down Expand Up @@ -65,6 +67,7 @@ public static Integer parseDateExpressionToInt(LocalDate localDate) {
+ localDate.getDayOfMonth();
}

// Do not use this method to get a timestamp, use parseIntToTimestamp instead.
public static Date parseIntToDate(int date) {
return new Date(date / 10000 - 1900, (date / 100) % 100 - 1, date % 100);
}
Expand All @@ -76,4 +79,10 @@ public static LocalDate parseIntToLocalDate(int date) {
throw new DateTimeParseException("Invalid date format.", "", 0);
}
}

public static long parseIntToTimestamp(int date, ZoneId zoneId) {
return ZonedDateTime.of(date / 10000, (date / 100) % 100, date % 100, 0, 0, 0, 0, zoneId)
.toInstant()
.toEpochMilli();
}
}