refactor: use system locale for date formatting

feat/data-edit-commands
William 11 months ago
parent cd298af5ae
commit b0e585841c
No known key found for this signature in database

@ -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

@ -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

@ -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(),

@ -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()) {

Loading…
Cancel
Save