Skip to content

Commit 8c06316

Browse files
committed
fix(rc): Set explicit English locale for date parsing
Fixes #1196
1 parent eee14b4 commit 8c06316

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/com/google/firebase/remoteconfig/RemoteConfigUtil.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.text.ParseException;
2424
import java.text.SimpleDateFormat;
2525
import java.util.Date;
26+
import java.util.Locale;
2627
import java.util.TimeZone;
2728

2829
final class RemoteConfigUtil {
@@ -53,15 +54,15 @@ static long convertToMilliseconds(String dateString) throws ParseException {
5354
static String convertToUtcZuluFormat(long millis) {
5455
// sample output date string: 2020-11-12T22:12:02.000000000Z
5556
checkArgument(millis >= 0, "Milliseconds duration must not be negative");
56-
SimpleDateFormat dateFormat = new SimpleDateFormat(ZULU_DATE_PATTERN);
57+
SimpleDateFormat dateFormat = new SimpleDateFormat(ZULU_DATE_PATTERN, Locale.ENGLISH);
5758
dateFormat.setTimeZone(UTC_TIME_ZONE);
5859
return dateFormat.format(new Date(millis));
5960
}
6061

6162
static String convertToUtcDateFormat(long millis) {
6263
// sample output date string: Tue, 08 Dec 2020 15:49:51 GMT
6364
checkArgument(millis >= 0, "Milliseconds duration must not be negative");
64-
SimpleDateFormat dateFormat = new SimpleDateFormat(UTC_DATE_PATTERN);
65+
SimpleDateFormat dateFormat = new SimpleDateFormat(UTC_DATE_PATTERN, Locale.ENGLISH);
6566
dateFormat.setTimeZone(UTC_TIME_ZONE);
6667
return dateFormat.format(new Date(millis));
6768
}
@@ -78,15 +79,16 @@ static long convertFromUtcZuluFormat(String dateString) throws ParseException {
7879
if (indexOfPeriod != -1) {
7980
dateString = dateString.substring(0, indexOfPeriod);
8081
}
81-
SimpleDateFormat dateFormat = new SimpleDateFormat(ZULU_DATE_NO_FRAC_SECS_PATTERN);
82+
SimpleDateFormat dateFormat =
83+
new SimpleDateFormat(ZULU_DATE_NO_FRAC_SECS_PATTERN, Locale.ENGLISH);
8284
dateFormat.setTimeZone(UTC_TIME_ZONE);
8385
return dateFormat.parse(dateString).getTime();
8486
}
8587

8688
static long convertFromUtcDateFormat(String dateString) throws ParseException {
8789
// sample input date string: Tue, 08 Dec 2020 15:49:51 GMT
8890
checkArgument(!Strings.isNullOrEmpty(dateString), "Date string must not be null or empty");
89-
SimpleDateFormat dateFormat = new SimpleDateFormat(UTC_DATE_PATTERN);
91+
SimpleDateFormat dateFormat = new SimpleDateFormat(UTC_DATE_PATTERN, Locale.ENGLISH);
9092
dateFormat.setTimeZone(UTC_TIME_ZONE);
9193
return dateFormat.parse(dateString).getTime();
9294
}

0 commit comments

Comments
 (0)