diff options
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/util/DateUtil.java')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/util/DateUtil.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/util/DateUtil.java b/src/main/java/com/keuin/kbackupfabric/util/DateUtil.java index b101cfd..7111347 100644 --- a/src/main/java/com/keuin/kbackupfabric/util/DateUtil.java +++ b/src/main/java/com/keuin/kbackupfabric/util/DateUtil.java @@ -1,13 +1,18 @@ package com.keuin.kbackupfabric.util; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.util.Date; public class DateUtil { + private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss"); + private static final SimpleDateFormat outFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private static final DateTimeFormatter prettyFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); public static String getString(LocalDateTime localDateTime) { return localDateTime.format(formatter); @@ -28,4 +33,12 @@ public class DateUtil { public static LocalDateTime toLocalDateTime(String timeString) { return LocalDateTime.parse(timeString, formatter); } + + public static String fromEpochMillis(long epochMillis) { + return outFormatter.format(new Date(epochMillis)); + } + + public static String getPrettyString(LocalDateTime localDateTime) { + return prettyFormatter.format(localDateTime); + } } |