public class NtpTrustedTime extends Object implements TrustedTime
TrustedTime
that connects with a remote NTP server as its trusted
time source.Modifier and Type | Method and Description |
---|---|
long |
currentTimeMillis()
Return current time similar to
System.currentTimeMillis() ,
possibly using a cached authoritative time source. |
boolean |
forceRefresh()
Force update with an external trusted time source, returning
true
when successful. |
long |
getCacheAge()
Return time since last trusted time source contact, or
Long.MAX_VALUE if never contacted. |
long |
getCacheCertainty()
Return certainty of cached trusted time in milliseconds, or
Long.MAX_VALUE if never contacted. |
long |
getCachedNtpTime() |
long |
getCachedNtpTimeReference() |
static NtpTrustedTime |
getInstance(Context context) |
boolean |
hasCache()
Check if this instance has cached a response from a trusted time source.
|
public static NtpTrustedTime getInstance(Context context)
public boolean forceRefresh()
TrustedTime
true
when successful.forceRefresh
in interface TrustedTime
public boolean hasCache()
TrustedTime
hasCache
in interface TrustedTime
public long getCacheAge()
TrustedTime
Long.MAX_VALUE
if never contacted.getCacheAge
in interface TrustedTime
public long getCacheCertainty()
TrustedTime
Long.MAX_VALUE
if never contacted. Smaller values are more
precise.getCacheCertainty
in interface TrustedTime
public long currentTimeMillis()
TrustedTime
System.currentTimeMillis()
,
possibly using a cached authoritative time source.currentTimeMillis
in interface TrustedTime
public long getCachedNtpTime()
public long getCachedNtpTimeReference()