GetCurrentRealTime

这计算当前设备时间并加上/减去实际和设备时间之间的差异

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;
}

获取基于 UTC 的时区。

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