diff --git a/src/main/java/org/cryptomator/common/settings/Settings.java b/src/main/java/org/cryptomator/common/settings/Settings.java index ef8398b01..6bfd03e3c 100644 --- a/src/main/java/org/cryptomator/common/settings/Settings.java +++ b/src/main/java/org/cryptomator/common/settings/Settings.java @@ -25,10 +25,7 @@ import javafx.beans.property.StringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.geometry.NodeOrientation; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.ZoneOffset; +import java.time.Instant; import java.util.Date; import java.util.function.Consumer; @@ -49,8 +46,8 @@ public class Settings { static final String DEFAULT_KEYCHAIN_PROVIDER = SystemUtils.IS_OS_WINDOWS ? "org.cryptomator.windows.keychain.WindowsProtectedKeychainAccess" : SystemUtils.IS_OS_MAC ? "org.cryptomator.macos.keychain.MacSystemKeychainAccess" : "org.cryptomator.linux.keychain.SecretServiceKeychainAccess"; static final String DEFAULT_USER_INTERFACE_ORIENTATION = NodeOrientation.LEFT_TO_RIGHT.name(); static final boolean DEFAULT_SHOW_MINIMIZE_BUTTON = false; - static final Date DEFAULT_LAST_UPDATE_REMINDER = Date.from(LocalDate.of(2000,1,1).atStartOfDay(ZoneId.systemDefault()).toInstant()); - public static final Date DEFAULT_LAST_SUCCESSFUL_UPDATE_CHECK = Date.from(LocalDateTime.of(2000,1,1,1,0,0).toInstant(ZoneOffset.UTC)); + static final Instant DEFAULT_LAST_UPDATE_REMINDER = Instant.ofEpochSecond(946681200); //2000-01-01T00:00:00Z + public static final Instant DEFAULT_LAST_SUCCESSFUL_UPDATE_CHECK = Instant.ofEpochSecond(946681200); //2000-01-01T00:00:00Z public final ObservableList directories; public final BooleanProperty askedForUpdateCheck; public final BooleanProperty checkForUpdates; @@ -72,8 +69,8 @@ public class Settings { public final IntegerProperty windowHeight; public final StringProperty language; public final StringProperty mountService; - public final ObjectProperty lastUpdateReminder; - public final ObjectProperty lastSuccessfulUpdateCheck; + public final ObjectProperty lastUpdateReminder; + public final ObjectProperty lastSuccessfulUpdateCheck; public final StringProperty latestVersion; private Consumer saveCmd; @@ -111,8 +108,8 @@ public class Settings { this.windowHeight = new SimpleIntegerProperty(this, "windowHeight", json.windowHeight); this.language = new SimpleStringProperty(this, "language", json.language); this.mountService = new SimpleStringProperty(this, "mountService", json.mountService); - this.lastUpdateReminder = new SimpleObjectProperty<>(this, "lastUpdateReminder", json.lastUpdateReminder); - this.lastSuccessfulUpdateCheck = new SimpleObjectProperty<>(this, "lastSuccessfulUpdateCheck", json.lastSuccessfulUpdateCheck); + this.lastUpdateReminder = new SimpleObjectProperty<>(this, "lastUpdateReminder", json.lastUpdateReminder.toInstant()); + this.lastSuccessfulUpdateCheck = new SimpleObjectProperty<>(this, "lastSuccessfulUpdateCheck", json.lastSuccessfulUpdateCheck.toInstant()); this.latestVersion = new SimpleStringProperty(this, "latestVersion", json.latestVersion); this.directories.addAll(json.directories.stream().map(VaultSettings::new).toList()); @@ -197,8 +194,8 @@ public class Settings { json.windowHeight = windowHeight.get(); json.language = language.get(); json.mountService = mountService.get(); - json.lastUpdateReminder = lastUpdateReminder.get(); - json.lastSuccessfulUpdateCheck = lastSuccessfulUpdateCheck.get(); + json.lastUpdateReminder = Date.from(lastUpdateReminder.get()); + json.lastSuccessfulUpdateCheck = Date.from(lastSuccessfulUpdateCheck.get()); json.latestVersion = latestVersion.get(); return json; } diff --git a/src/main/java/org/cryptomator/common/settings/SettingsJson.java b/src/main/java/org/cryptomator/common/settings/SettingsJson.java index e136e6f60..7161b932a 100644 --- a/src/main/java/org/cryptomator/common/settings/SettingsJson.java +++ b/src/main/java/org/cryptomator/common/settings/SettingsJson.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import java.time.LocalDate; import java.util.Date; import java.util.List; @@ -85,11 +84,11 @@ class SettingsJson { @JsonProperty("lastUpdateReminder") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") - Date lastUpdateReminder = Settings.DEFAULT_LAST_UPDATE_REMINDER; + Date lastUpdateReminder = Date.from(Settings.DEFAULT_LAST_UPDATE_REMINDER); @JsonProperty("lastSuccessfulUpdateCheck") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") - Date lastSuccessfulUpdateCheck = Settings.DEFAULT_LAST_SUCCESSFUL_UPDATE_CHECK; + Date lastSuccessfulUpdateCheck = Date.from(Settings.DEFAULT_LAST_SUCCESSFUL_UPDATE_CHECK); @JsonProperty("latestVersion") String latestVersion;