GetCurrentRealTime

suggest change

This calculate current device time and add/subtract difference between real and device time

public static Calendar getCurrentRealTime() {

    long bootTime = networkTime - SystemClock.elapsedRealtime();
    Calendar calInstance = Calendar.getInstance();
    calInstance.setTimeZone(getUTCTimeZone());
    long currentDeviceTime = bootTime + SystemClock.elapsedRealtime();
    calInstance.setTimeInMillis(currentDeviceTime);
    return calInstance;
}

get UTC based timezone.

public static TimeZone getUTCTimeZone() {
    return TimeZone.getTimeZone("GMT");
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents