diff --git a/src/main/java/com/google/firebase/internal/DateUtils.java b/src/main/java/com/google/firebase/internal/DateUtils.java index 6c4eeb7b0..a55fac8c0 100644 --- a/src/main/java/com/google/firebase/internal/DateUtils.java +++ b/src/main/java/com/google/firebase/internal/DateUtils.java @@ -20,6 +20,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import java.util.Locale; import java.util.TimeZone; /** @@ -57,9 +58,9 @@ final class DateUtils { static final String PATTERN_ASCTIME = "EEE MMM d HH:mm:ss yyyy"; private static final SimpleDateFormat[] DEFAULT_PATTERNS = new SimpleDateFormat[] { - new SimpleDateFormat(PATTERN_RFC1123), - new SimpleDateFormat(PATTERN_RFC1036), - new SimpleDateFormat(PATTERN_ASCTIME) + new SimpleDateFormat(PATTERN_RFC1123, Locale.US), + new SimpleDateFormat(PATTERN_RFC1036, Locale.US), + new SimpleDateFormat(PATTERN_ASCTIME, Locale.US) }; static final TimeZone GMT = TimeZone.getTimeZone("GMT"); diff --git a/src/test/java/com/google/firebase/internal/RetryUnsuccessfulResponseHandlerTest.java b/src/test/java/com/google/firebase/internal/RetryUnsuccessfulResponseHandlerTest.java index 077e9e52f..f0bc2d0b3 100644 --- a/src/test/java/com/google/firebase/internal/RetryUnsuccessfulResponseHandlerTest.java +++ b/src/test/java/com/google/firebase/internal/RetryUnsuccessfulResponseHandlerTest.java @@ -35,7 +35,9 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Locale; import java.util.TimeZone; + import org.junit.Test; public class RetryUnsuccessfulResponseHandlerTest { @@ -137,7 +139,8 @@ public void testRetryAfterGivenAsSeconds() throws IOException { @Test public void testRetryAfterGivenAsDate() throws IOException { - SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"); + SimpleDateFormat dateFormat = + new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); Date date = new Date(1000); Clock clock = new FixedClock(date.getTime()); diff --git a/src/test/java/com/google/firebase/messaging/MessageTest.java b/src/test/java/com/google/firebase/messaging/MessageTest.java index 7c8f528df..562466f4a 100644 --- a/src/test/java/com/google/firebase/messaging/MessageTest.java +++ b/src/test/java/com/google/firebase/messaging/MessageTest.java @@ -33,6 +33,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.concurrent.TimeUnit; import org.junit.Test; @@ -769,7 +770,7 @@ public void testImageInAndroidNotification() throws IOException { assertJsonEquals(ImmutableMap.of( "topic", "test-topic", "notification", notification, "android", androidConfig), message); } - + @Test public void testImageInApnsNotification() throws IOException { Message message = Message.builder() @@ -799,7 +800,7 @@ public void testImageInApnsNotification() throws IOException { .build(); assertJsonEquals(expected, message); } - + @Test public void testInvalidColorInAndroidNotificationLightSettings() throws IOException { try { @@ -814,7 +815,7 @@ public void testInvalidColorInAndroidNotificationLightSettings() throws IOExcept // expected } } - + @Test public void testExtendedAndroidNotificationParameters() throws IOException { long[] vibrateTimings = {1000L, 1001L}; @@ -848,7 +849,7 @@ public void testExtendedAndroidNotificationParameters() throws IOException { .put("title", "title") .put("body", "body") .build(); - String eventTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS'Z'") + String eventTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS'Z'", Locale.US) .format(new Date(1546304523123L)); Map androidConfig = ImmutableMap.builder() .put("notification", ImmutableMap.builder()