Skip to content

Set date format locale to english #3873

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

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ private JSONObject createFetchRequestBody(
}

private String convertToISOString(long millisFromEpoch) {
SimpleDateFormat isoDateFormat = new SimpleDateFormat(ISO_DATE_PATTERN);
SimpleDateFormat isoDateFormat = new SimpleDateFormat(ISO_DATE_PATTERN, Locale.ENGLISH);
isoDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
return isoDateFormat.format(millisFromEpoch);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,22 @@ public void fetch_setsAllElementsOfRequestBody_sendsRequestBodyToServer() throws
.isEqualTo(new JSONObject(customUserProperties).toString());
}

@Test
public void fetch_firstOpenTimeWithArabicLocale_fieldPresentInEnglishLocale() throws Exception {
Locale.setDefault(new Locale("ar", "AE"));
setServerResponseTo(noChangeResponseBody, SECOND_ETAG);
Map<String, String> customUserProperties = ImmutableMap.of("up1", "hello", "up2", "world");

long firstOpenTimeEpochFromMillis = 1636146000000L;
// ISO-8601 value corresponding to 1636146000000 ms-from-epoch in UTC
String firstOpenTimeIsoString = "2021-11-05T21:00:00.000Z";

fetch(FIRST_ETAG, customUserProperties, firstOpenTimeEpochFromMillis);

JSONObject requestBody = new JSONObject(fakeHttpURLConnection.getOutputStream().toString());
assertThat(requestBody.get(FIRST_OPEN_TIME)).isEqualTo(firstOpenTimeIsoString);
}

@Test
public void fetch_nullFirstOpenTime_fieldNotPresentInRequestBody() throws Exception {
setServerResponseTo(noChangeResponseBody, SECOND_ETAG);
Expand Down