From f84f64397573972e7c9da379cba62bf1b691b060 Mon Sep 17 00:00:00 2001 From: LOOHP Date: Sun, 29 Dec 2024 11:59:15 +0000 Subject: [PATCH] Switch to ZonedDateTime --- build.gradle.kts | 2 +- .../expansion/server/util/TimeFormatter.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 04145fb..7a52b09 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,7 @@ repositories { dependencies { compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT") - compileOnly("me.clip:placeholderapi:2.11.3") + compileOnly("me.clip:placeholderapi:2.11.6") } tasks { diff --git a/src/main/java/at/helpch/placeholderapi/expansion/server/util/TimeFormatter.java b/src/main/java/at/helpch/placeholderapi/expansion/server/util/TimeFormatter.java index 05de674..46d7539 100644 --- a/src/main/java/at/helpch/placeholderapi/expansion/server/util/TimeFormatter.java +++ b/src/main/java/at/helpch/placeholderapi/expansion/server/util/TimeFormatter.java @@ -7,8 +7,8 @@ import org.jetbrains.annotations.Nullable; import java.time.DateTimeException; -import java.time.LocalDateTime; import java.time.ZoneId; +import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoUnit; @@ -64,7 +64,7 @@ public TimeFormatter( * Format the current time with the given format * * @param format format - * @return {@code null} if the format is empty or invalid, otherwise {@link LocalDateTime#now(ZoneId)} formatted + * @return {@code null} if the format is empty or invalid, otherwise {@link ZonedDateTime#now(ZoneId)} formatted */ public @Nullable String formatTime(@NotNull final String format) { if (format.trim().isEmpty()) { @@ -72,7 +72,7 @@ public TimeFormatter( } return Optional.ofNullable(parseFormat(format)) - .map(formatter -> LocalDateTime.now(timeZone).format(formatter)) + .map(formatter -> ZonedDateTime.now(timeZone).format(formatter)) .orElse(null); } @@ -110,7 +110,7 @@ public TimeFormatter( } /** - * Calculate the time between {@link LocalDateTime#now(ZoneId)} and another date and return a formatted value + * Calculate the time between {@link ZonedDateTime#now(ZoneId)} and another date and return a formatted value * using {@link #formatTimeInSeconds(long)} if {@code formatTime} is {@code true}. * * @param player player @@ -146,8 +146,8 @@ public TimeFormatter( } try { - LocalDateTime now = LocalDateTime.now(timeZone); - LocalDateTime otherDate = LocalDateTime.parse(otherDateString, formatter); + ZonedDateTime now = ZonedDateTime.now(timeZone); + ZonedDateTime otherDate = ZonedDateTime.parse(otherDateString, formatter); if (otherDate.isEqual(now)) { return "0";