From 50f20d4dcdf5c7605541de5d2a1a9bbb5f1bf9bc Mon Sep 17 00:00:00 2001 From: Ahmad Vazirna Date: Fri, 8 Sep 2023 23:58:31 +0200 Subject: [PATCH] Set locale to date format --- .../core/network/CommCareNetworkServiceGenerator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/commcare/core/network/CommCareNetworkServiceGenerator.java b/src/main/java/org/commcare/core/network/CommCareNetworkServiceGenerator.java index d50a9c5558..17e0ae88ef 100644 --- a/src/main/java/org/commcare/core/network/CommCareNetworkServiceGenerator.java +++ b/src/main/java/org/commcare/core/network/CommCareNetworkServiceGenerator.java @@ -12,9 +12,11 @@ import org.javarosa.core.services.Logger; import java.io.IOException; +import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Locale; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -73,8 +75,10 @@ public class CommCareNetworkServiceGenerator { ICommCarePreferenceManager commCarePreferenceManager = CommCarePreferenceManagerFactory.getCommCarePreferenceManager(); if (commCarePreferenceManager != null) { String serverDate = response.header("date"); + try { - long serverTimeInMillis = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss zzz").parse(serverDate).getTime(); + long serverTimeInMillis = new SimpleDateFormat( + "EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH).parse(serverDate).getTime(); long now = new Date().getTime(); long currentDrift = (now - serverTimeInMillis) / HOUR_IN_MS; commCarePreferenceManager.putLong(CURRENT_DRIFT, currentDrift); @@ -90,6 +94,8 @@ public class CommCareNetworkServiceGenerator { return response; }; + + private static AuthenticationInterceptor authenticationInterceptor = new AuthenticationInterceptor(); private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder()