Holger's
Java API

com.antelmann.calendar
Class NTPClient

java.lang.Object
  extended by com.antelmann.calendar.AbstractTimeSystem
      extended by com.antelmann.calendar.NTPClient
All Implemented Interfaces:
TimeSystem

public class NTPClient
extends AbstractTimeSystem

implements a simple client for the Network Time Protocol (NTP).

Author:
Holger Antelmann
See Also:
NTPTime

Field Summary
static int DEFAULT_PORT
          123
static String DEFAULT_SERVER_KEY
          key to obtain the default server via Settings.getProperty(String)
static String DEFAULT_SERVER_LIST_KEY
          key to obtain the default server list via Settings.getProperty(String)
static double TIME_OFFSET
          seconds between Jan-01-1990 and Jan-01-1970
 
Fields inherited from interface com.antelmann.calendar.TimeSystem
SYSTEM_TIME
 
Constructor Summary
NTPClient()
           
NTPClient(String serverName)
           
NTPClient(String serverName, int port)
           
 
Method Summary
protected  long aquireDelta()
          returns the current difference between system time and the time of this implementation in milliseconds.
static String getDefaultServer()
           
static String[] getDefaultServerList()
           
 int getPort()
           
 String getServer()
           
 int getTimeout()
           
static void setDefaultServer(String server)
           
static void setDefaultServerList(String... serverList)
           
 void setPort(int port)
           
 void setServer(String serverName)
           
 void setTimeout(int timeout)
           
 String toString()
           
 
Methods inherited from class com.antelmann.calendar.AbstractTimeSystem
adjustDelta, adjustedTimeMills, createTimerTask, currentTimeMillis, getDelta, getLastDeltaAdjustmentTime, getLastRoundTripDelay, setDelta, setLastRoundTripDelay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SERVER_KEY

public static final String DEFAULT_SERVER_KEY
key to obtain the default server via Settings.getProperty(String)

See Also:
Constant Field Values

DEFAULT_SERVER_LIST_KEY

public static final String DEFAULT_SERVER_LIST_KEY
key to obtain the default server list via Settings.getProperty(String)

See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
123

See Also:
Constant Field Values

TIME_OFFSET

public static final double TIME_OFFSET
seconds between Jan-01-1990 and Jan-01-1970

See Also:
Constant Field Values
Constructor Detail

NTPClient

public NTPClient()

NTPClient

public NTPClient(String serverName)

NTPClient

public NTPClient(String serverName,
                 int port)
Method Detail

getServer

public String getServer()

setServer

public void setServer(String serverName)

getPort

public int getPort()

setPort

public void setPort(int port)

setTimeout

public void setTimeout(int timeout)

getTimeout

public int getTimeout()

aquireDelta

protected long aquireDelta()
                    throws IOException
Description copied from class: AbstractTimeSystem
returns the current difference between system time and the time of this implementation in milliseconds. A negative number indicates that the system clock is behind. Calling this method does not affect the delta value of this instance.

Specified by:
aquireDelta in class AbstractTimeSystem
Throws:
IOException
See Also:
AbstractTimeSystem.adjustDelta()

toString

public String toString()
Overrides:
toString in class Object

getDefaultServer

public static String getDefaultServer()
See Also:
DEFAULT_SERVER_KEY

setDefaultServer

public static void setDefaultServer(String server)

getDefaultServerList

public static String[] getDefaultServerList()
See Also:
DEFAULT_SERVER_LIST_KEY

setDefaultServerList

public static void setDefaultServerList(String... serverList)


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads