Skip to content

Commit

Permalink
Merge pull request #1336 from dimagi/copy_of_android_13_update
Browse files Browse the repository at this point in the history
Duplicate of android_13_update
  • Loading branch information
shubham1g5 authored Sep 25, 2023
2 parents 11ac1d1 + 50f20d4 commit 2e00d50
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -90,6 +94,8 @@ public class CommCareNetworkServiceGenerator {
return response;
};



private static AuthenticationInterceptor authenticationInterceptor = new AuthenticationInterceptor();

private static OkHttpClient.Builder httpClient = new OkHttpClient.Builder()
Expand Down

0 comments on commit 2e00d50

Please sign in to comment.