Skip to content

Commit

Permalink
Merge pull request #1329 from dimagi/android_13_update
Browse files Browse the repository at this point in the history
Android 13 update
  • Loading branch information
avazirna authored Sep 21, 2023
2 parents ac64d2b + 5db37b9 commit fe9fea0
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 fe9fea0

Please sign in to comment.