Skip to content
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

Duplicate of android_13_update #1336

Merged
merged 1 commit into from
Sep 25, 2023
Merged
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 @@ -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