summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/util/DateUtil.java
diff options
context:
space:
mode:
authorKeuin <[email protected]>2021-01-25 15:25:34 +0800
committerKeuin <[email protected]>2021-01-25 15:25:34 +0800
commit08ac6aaea58b7309ea95a12ca6227a6ca3ce4db5 (patch)
treed305fc23d2cec9935ccb5e5a5390c9d5e54a8726 /src/main/java/com/keuin/kbackupfabric/util/DateUtil.java
parenta817715ad4f625e355b285d67ee323e8b2006ae4 (diff)
Improve user interaction.
Code refactor.
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/util/DateUtil.java')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/util/DateUtil.java13
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);
+ }
}