summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/backup/name/PrimitiveBackupFileNameEncoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/backup/name/PrimitiveBackupFileNameEncoder.java')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/backup/name/PrimitiveBackupFileNameEncoder.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/backup/name/PrimitiveBackupFileNameEncoder.java b/src/main/java/com/keuin/kbackupfabric/backup/name/PrimitiveBackupFileNameEncoder.java
index c8e73f9..1deec8f 100644
--- a/src/main/java/com/keuin/kbackupfabric/backup/name/PrimitiveBackupFileNameEncoder.java
+++ b/src/main/java/com/keuin/kbackupfabric/backup/name/PrimitiveBackupFileNameEncoder.java
@@ -1,19 +1,19 @@
package com.keuin.kbackupfabric.backup.name;
+import com.keuin.kbackupfabric.util.DateUtil;
+
import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PrimitiveBackupFileNameEncoder implements BackupFileNameEncoder {
private static final String backupFileNamePrefix = "kbackup";
- private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss");
@Override
public String encode(String customName, LocalDateTime time) {
if (!isValidCustomName(customName))
throw new IllegalArgumentException("Invalid custom name");
- String timeString = time.format(formatter);
+ String timeString = DateUtil.getString(time);
return backupFileNamePrefix + "-" + timeString + "_" + customName + ".zip";
}
@@ -26,7 +26,7 @@ public class PrimitiveBackupFileNameEncoder implements BackupFileNameEncoder {
if (matcher.find()) {
String timeString = matcher.group(1);
String customName = matcher.group(2);
- return new BackupBasicInformation(customName, LocalDateTime.parse(timeString, formatter));
+ return new BackupBasicInformation(customName, DateUtil.toLocalDateTime(timeString));
}
return null;
}