|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.calendar.AtomicClock
public class AtomicClock
uses the Network Time Protocol (NTP). This simple implementation is based on a single server.
NTPServer,
AtomicTime| Field Summary | |
|---|---|
static int |
DEFAULT_NTP_PORT
37 |
static String |
DEFAULT_NTP_SERVER
time-b.nist.gov |
protected static String[] |
knownServerList
a small list of known servers besides the default one |
| Fields inherited from interface com.antelmann.calendar.TimeSystem |
|---|
systemTime |
| Constructor Summary | |
|---|---|
AtomicClock()
uses time-b.nist.gov |
|
AtomicClock(String serverName)
uses the standard port 37 |
|
AtomicClock(String serverName,
int port)
|
|
| Method Summary | |
|---|---|
int |
adjustDelta()
adjusts the delta value used for getTime() through
using the server time |
TimerTask |
createTimerTask(Logger logger)
creates a TimerTask that will adjust the delta and log the result to the given logger. |
int |
currentDelta()
returns the current difference between system time and atomic time in milliseconds. |
long |
currentTimeMillis()
returns the system time adjusted by the delta value. |
long |
currentTimeMillisOnline()
returns the current time in the current locale retrieved directly from the server. |
Calendar |
getCalendar()
returns the calendar used to localize the time |
int |
getDelta()
returns the stored difference between system time and atomic time in milliseconds. |
static String[] |
getKnownServerList()
|
long |
getLastDeltaAdjustmentTime()
returns the system time when adjustDelta() has been
successfully called last time. |
int |
getPort()
|
String |
getServer()
|
int |
getTimeout()
|
static void |
main(String[] args)
console based demo app displaying the delta between the system time and the server |
protected int |
secondsSince1900()
returns the raw int directly from the server |
void |
setDelta(int delta)
manually sets the value used to adjust system time |
static void |
setKnownServerList(String[] newList)
|
void |
setPort(int port)
|
void |
setServer(String serverName)
|
void |
setTimeout(int timeout)
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_NTP_SERVER
public static final int DEFAULT_NTP_PORT
protected static String[] knownServerList
| Constructor Detail |
|---|
public AtomicClock()
public AtomicClock(String serverName)
public AtomicClock(String serverName,
int port)
| Method Detail |
|---|
public static String[] getKnownServerList()
public static void setKnownServerList(String[] newList)
public String getServer()
public void setServer(String serverName)
public int getPort()
public void setPort(int port)
public void setTimeout(int timeout)
public int getTimeout()
public Calendar getCalendar()
public long currentTimeMillis()
currentTimeMillis in interface TimeSystem
protected int secondsSince1900()
throws IOException
IOException
public long currentTimeMillisOnline()
throws IOException
IOException
public int currentDelta()
throws IOException
IOExceptionpublic int getDelta()
adjustDelta(),
setDelta(int)public void setDelta(int delta)
adjustDelta()public long getLastDeltaAdjustmentTime()
adjustDelta() has been
successfully called last time.
If no sucessful adjustment has taken place, yet, the method returns 0.
adjustDelta()
public int adjustDelta()
throws IOException
getTime() through
using the server time
IOExceptioncurrentTimeMillis(),
getDelta(),
setDelta(int),
getLastDeltaAdjustmentTime()public TimerTask createTimerTask(Logger logger)
adjustDelta(),
Timerpublic String toString()
toString in class Object
public static void main(String[] args)
throws IOException
IOException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||