Date conversion functions
You can use the date conversion functions to convert the date or time from one format to another.
| Implementation | Purpose |
|---|---|
|
Long toTimestamp(String dateConstant) {
LocalDateTime.of(
LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE.parse(dateConstant)),
LocalTime.of(0, 0, 0)
).atOffset(ZoneOffset.UTC).toInstant().toEpochMilli()
}
|
Converts the date constant to the time stamp.
|
|
String toDateConstant(Long timestamp) {
Instant.ofEpochMilli(timestamp).atOffset(ZoneOffset.UTC)
.format(DateTimeFormatter.ISO_LOCAL_DATE)
}
|
Converts the time stamp to a date string in the
|
|
String toDateConstant(Long timestamp, String pattern) {
Instant.ofEpochMilli(timestamp).atOffset(ZoneOffset.UTC)
.format(DateTimeFormatter.ofPattern(pattern, ValidationConfig.getInstance().getLocale()))
}
|
Converts the time stamp to a string using the given pattern.
|
|
String now() {
Instant.now().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_LOCAL_DATE)
}
|
Returns the current date string in the
|