From 0b00f3bdbe0c741661bba81a4b49a81839dc81e0 Mon Sep 17 00:00:00 2001 From: Kenneth Seet Date: Tue, 6 Aug 2024 15:14:17 +0800 Subject: [PATCH 1/2] Standardize locale --- src/main/java/teammates/common/util/TimeHelper.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/teammates/common/util/TimeHelper.java b/src/main/java/teammates/common/util/TimeHelper.java index de7d58f796a..f3a5ed482a4 100644 --- a/src/main/java/teammates/common/util/TimeHelper.java +++ b/src/main/java/teammates/common/util/TimeHelper.java @@ -7,6 +7,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; +import java.util.Locale; /** * A helper class to hold time-related functions (e.g., converting dates to strings etc.). @@ -105,7 +106,9 @@ public static String formatInstant(Instant instant, String timeZone, String patt if (zonedDateTime.getHour() == 12 && zonedDateTime.getMinute() == 0) { processedPattern = pattern.replace("a", "'NOON'"); } - DateTimeFormatter formatter = DateTimeFormatter.ofPattern(processedPattern); + DateTimeFormatter formatter = DateTimeFormatter + .ofPattern(processedPattern) + .withLocale(Locale.US); return zonedDateTime.format(formatter); } From 8d38f69f0ccb29f0c654dd48ff460ca56bb0594a Mon Sep 17 00:00:00 2001 From: Kenneth Seet Date: Thu, 8 Aug 2024 01:07:29 +0800 Subject: [PATCH 2/2] Add DecimalFormatSymbols --- src/main/java/teammates/common/util/StringHelper.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/teammates/common/util/StringHelper.java b/src/main/java/teammates/common/util/StringHelper.java index 653b52a7d9a..b955b54b23c 100644 --- a/src/main/java/teammates/common/util/StringHelper.java +++ b/src/main/java/teammates/common/util/StringHelper.java @@ -1,6 +1,7 @@ package teammates.common.util; import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; import java.util.Collections; import java.util.List; import java.util.Objects; @@ -179,7 +180,9 @@ public static String toString(List list, String delimiter) { * Converts a double value between 0 and 1 to 3dp-string. */ public static String toDecimalFormatString(double doubleVal) { - DecimalFormat df = new DecimalFormat("0.###"); + DecimalFormatSymbols syms = new DecimalFormatSymbols(); + syms.setDecimalSeparator('.'); + DecimalFormat df = new DecimalFormat("0.###", syms); return df.format(doubleVal); }