Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#8557] Standardize locale #13162

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/java/teammates/common/util/StringHelper.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -179,7 +180,9 @@ public static <T> String toString(List<T> 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);
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/teammates/common/util/TimeHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.).
Expand Down Expand Up @@ -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);
}

Expand Down
Loading