diff options
author | Keuin <[email protected]> | 2020-04-24 11:55:18 +0800 |
---|---|---|
committer | keuin <[email protected]> | 2020-04-24 11:55:18 +0800 |
commit | b692a73e039fbdb404ef1219785660dc9eb60e60 (patch) | |
tree | 598351d6fcf5f4dcad0212e4cca37ffc16966e0d /src/main/java/com/keuin/kbackupfabric/util/BackupNameTimeFormatter.java | |
parent | 87f5cd97ab22b17a948eb9af1b49a0b1e777048d (diff) |
Added /kb delete <backup_name> for deleting an backup (with auto-complete supported).
Command /kb confirm now confirms both /kb restore and /kb delete.
Added /kb prev for easily check out the latest backup.
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/util/BackupNameTimeFormatter.java')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/util/BackupNameTimeFormatter.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/util/BackupNameTimeFormatter.java b/src/main/java/com/keuin/kbackupfabric/util/BackupNameTimeFormatter.java new file mode 100644 index 0000000..5d00270 --- /dev/null +++ b/src/main/java/com/keuin/kbackupfabric/util/BackupNameTimeFormatter.java @@ -0,0 +1,22 @@ +package com.keuin.kbackupfabric.util; + +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; + +public class BackupNameTimeFormatter { + private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss"); + + public static String getTimeString() { + return LocalDateTime.now().format(formatter); + } + + public static long timeStringToEpochSeconds(String timeString) { + ZoneId systemZone = ZoneId.systemDefault(); // my timezone + LocalDateTime localDateTime = LocalDateTime.parse(timeString, formatter); + ZoneOffset currentOffsetForMyZone = systemZone.getRules().getOffset(localDateTime); + return localDateTime.toEpochSecond(currentOffsetForMyZone); + } + +} |