## net.i2p.time
Class NtpClient

    java.lang.Object
      net.i2p.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.

Author:
  Adam Buckley (minor refactoring by jrandom)

Constructor Summary
`NtpClient()`

Method Summary
`static long` `currentTime(String serverName)` Query the given NTP server, returning the current internet time
`static long` `currentTime(String[] serverNames)` Query the ntp servers, returning the current time from first one we find
`static long[]` `currentTimeAndStratum(String[] serverNames)` Query the ntp servers, returning the current time from first one we find Hack to return time and stratum
`static void` `main(String[] args)`
`(package private) static void` `printUsage()` Prints usage

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### NtpClient

    public NtpClient()

Method Detail

### currentTime

    public static long currentTime(String[] serverNames)

  Query the ntp servers, returning the current time from first one we find

  Returns:
    milliseconds since january 1, 1970 (UTC)
  Throws:
    `IllegalArgumentException` - if none of the servers are reachable

### currentTimeAndStratum

    public static long[] currentTimeAndStratum(String[] serverNames)

  Query the ntp servers, returning the current time from first one we find Hack to return time and stratum

  Returns:
    time in rv[0] and stratum in rv[1]
  Throws:
    `IllegalArgumentException` - if none of the servers are reachable
  Since:
    0.7.12

### currentTime

    public static long currentTime(String serverName)

  Query the given NTP server, returning the current internet time

  Returns:
    milliseconds since january 1, 1970 (UTC), or -1 on error

### main

    public static void main(String[] args)
                     throws IOException

  Throws:
    `IOException`

### printUsage

    static void printUsage()

  Prints usage