Package net.i2p.router.time
Class NtpClient
- java.lang.Object
-
- net.i2p.router.time.NtpClient
-
public class NtpClient extends Object
NtpClient - an NTP client for Java. This program connects to an NTP server and prints the response to the console. The local clock offset calculation is implemented according to the SNTP algorithm specified in RFC 2030. Note that on windows platforms, the curent time-of-day timestamp is limited to an resolution of 10ms and adversely affects the accuracy of the results. Public only for main(), not a public API, not for external use. 2036-compliant as of 0.9.50, see NtpMessage.- Since:
- 0.9.1 moved from net.i2p.time
- Author:
- Adam Buckley (minor refactoring by jrandom)
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static double
SECONDS_1900_TO_EPOCH
difference between the unix epoch and jan 1 1900 (NTP uses that)
-
Constructor Summary
Constructors Constructor Description NtpClient()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static long[]
currentTimeAndStratum(String[] serverNames, int perServerTimeout, boolean preferIPv6, Log log)
Query the ntp servers, returning the current time from first one we find Hack to return time and stratumstatic void
main(String[] args)
Usage: NtpClient [-6] [servers...] default pool.ntp.org
-
-
-
Field Detail
-
SECONDS_1900_TO_EPOCH
static final double SECONDS_1900_TO_EPOCH
difference between the unix epoch and jan 1 1900 (NTP uses that)- See Also:
- Constant Field Values
-
-
Method Detail
-
currentTimeAndStratum
static long[] currentTimeAndStratum(String[] serverNames, int perServerTimeout, boolean preferIPv6, Log log)
Query the ntp servers, returning the current time from first one we find Hack to return time and stratum- Parameters:
log
- may be null- Returns:
- time in rv[0] and stratum in rv[1]
- Throws:
IllegalArgumentException
- if none of the servers are reachable- Since:
- 0.7.12
-
main
public static void main(String[] args) throws IOException
Usage: NtpClient [-6] [servers...] default pool.ntp.org- Throws:
IOException
-
-