org.apache.commons.net
public final class TimeUDPClient extends DatagramSocketClient
open
and call getTime
or
getDate
to retrieve the time. Then call
close
to close the connection properly. Unlike
TimeTCPClient,
successive calls to getTime
or
getDate
are permitted
without re-establishing a connection. That is because UDP is a
connectionless protocol and the Time protocol is stateless.
Field Summary | |
---|---|
static int | DEFAULT_PORT The default time port. |
static long | SECONDS_1900_TO_1970
The number of seconds between 00:00 1 January 1900 and
00:00 1 January 1970. |
Method Summary | |
---|---|
Date | getDate(InetAddress host, int port)
Retrieves the time from the server and returns a Java Date
containing the time converted to the local timezone.
|
Date | getDate(InetAddress host) Same as getTime(host, DEFAULT_PORT); ** |
long | getTime(InetAddress host, int port)
Retrieves the time from the specified server and port and
returns it. |
long | getTime(InetAddress host) Same as getTime(host, DEFAULT_PORT); ** |
Parameters: host The address of the server. port The port of the service.
Returns: A Date value containing the time retrieved from the server converted to the local timezone.
Throws: IOException If an error occurs while fetching the time.
getTime(host, DEFAULT_PORT);
**Parameters: host The address of the server. port The port of the service.
Returns: The time value retrieved from the server.
Throws: IOException If an error occurs while retrieving the time.
getTime(host, DEFAULT_PORT);
**