From 1e698b9400d2c684cecc60ba69fb77c584bf3d82 Mon Sep 17 00:00:00 2001 From: 1a2s3d4f1 <40121560+1a2s3d4f1@users.noreply.github.com> Date: Thu, 30 Jan 2020 08:57:18 +0800 Subject: [PATCH] Compatible Windows ":" can not write to file name if the system is windows --- .../net/szum123321/textile_backup/core/BackupHelper.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/szum123321/textile_backup/core/BackupHelper.java b/src/main/java/net/szum123321/textile_backup/core/BackupHelper.java index 22de8b5..38f5dc5 100644 --- a/src/main/java/net/szum123321/textile_backup/core/BackupHelper.java +++ b/src/main/java/net/szum123321/textile_backup/core/BackupHelper.java @@ -99,6 +99,11 @@ public class BackupHelper { } public static DateTimeFormatter getDateTimeFormatter(){ - return DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm:ss"); + String os = System.getProperty("os.name"); + if (os.toLowerCase().startsWith("win")) { + return DateTimeFormatter.ofPattern("dd.MM.yyyy_HH-mm-ss"); + } else { + return DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm:ss"); + } } }