9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2025-12-23 08:39:19 +00:00

refactor: use system locale for date formatting

This commit is contained in:
William
2024-04-07 12:44:58 +01:00
parent cd298af5ae
commit b0e585841c
4 changed files with 12 additions and 5 deletions

View File

@@ -30,6 +30,7 @@ import net.william278.husksync.user.User;
import org.jetbrains.annotations.NotNull;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.List;
import java.util.Optional;
@@ -51,7 +52,8 @@ public class EnderChestCommand extends ItemsCommand {
// Display opening message
plugin.getLocales().getLocale("ender_chest_viewer_opened", user.getUsername(),
snapshot.getTimestamp().format(DateTimeFormatter.ofPattern("dd/MM/yyyy, HH:mm")))
snapshot.getTimestamp().format(DateTimeFormatter
.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT)))
.ifPresent(viewer::sendMessage);
// Show GUI

View File

@@ -30,6 +30,7 @@ import net.william278.husksync.user.User;
import org.jetbrains.annotations.NotNull;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.List;
import java.util.Optional;
@@ -51,7 +52,8 @@ public class InventoryCommand extends ItemsCommand {
// Display opening message
plugin.getLocales().getLocale("inventory_viewer_opened", user.getUsername(),
snapshot.getTimestamp().format(DateTimeFormatter.ofPattern("dd/MM/yyyy, HH:mm")))
snapshot.getTimestamp().format(DateTimeFormatter
.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT)))
.ifPresent(viewer::sendMessage);
// Show GUI

View File

@@ -27,6 +27,7 @@ import net.william278.paginedown.PaginatedList;
import org.jetbrains.annotations.NotNull;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -53,9 +54,9 @@ public class DataSnapshotList {
snapshot.getShortId(),
snapshot.isPinned() ? "" : " ",
snapshot.getTimestamp().format(DateTimeFormatter
.ofPattern("dd/MM/yyyy, HH:mm")),
.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT)),
snapshot.getTimestamp().format(DateTimeFormatter
.ofPattern("MMM dd yyyy, HH:mm:ss.SSS")),
.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.LONG)),
snapshot.getSaveCause().getLocale(plugin),
String.format("%.2fKiB", snapshot.getFileSize(plugin) / 1024f))
.orElse("" + snapshot.getId())).toList(),

View File

@@ -28,6 +28,7 @@ import net.william278.husksync.user.User;
import org.jetbrains.annotations.NotNull;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
@@ -61,7 +62,8 @@ public class DataSnapshotOverview {
dataOwner.getUsername(), dataOwner.getUuid().toString())
.ifPresent(user::sendMessage);
locales.getLocale("data_manager_timestamp",
snapshot.getTimestamp().format(DateTimeFormatter.ofPattern("MMM dd yyyy, HH:mm:ss.SSS")),
snapshot.getTimestamp().format(DateTimeFormatter
.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.LONG)),
snapshot.getTimestamp().toString())
.ifPresent(user::sendMessage);
if (snapshot.isPinned()) {