diff --git a/src/main/java/org/commcare/core/network/CommCareNetworkServiceGenerator.java b/src/main/java/org/commcare/core/network/CommCareNetworkServiceGenerator.java index d50a9c555..17e0ae88e 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()