public class NtpUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
NTP_ATTEMPTS_PROPERTY
Property to set the NTP attempts.
|
static int |
NTP_DEFAULT_ATTEMPTS
Default NTP attempts.
|
static int |
NTP_DEFAULT_GUARD_TIME
Default NTP guard time.
|
static int |
NTP_DEFAULT_PORT
Default NTP port.
|
static String |
NTP_DEFAULT_SERVER
Default NTP URL.
|
static int |
NTP_DEFAULT_TIMEOUT
Default NTP timeout.
|
static String |
NTP_GUARD_TIME_PROPERTY
Property to set the NTP guard time.
|
static String |
NTP_PORT_PROPERTY
Property to set the NTP port.
|
static String |
NTP_TIMEOUT_PROPERTY
Property to set the NTP timeout.
|
static String |
NTP_URL_PROPERTY
Property to set the NTP URL.
|
Modifier and Type | Method and Description |
---|---|
static void |
updateLocalTime()
Updates the local time.
|
static void |
updateLocalTime(String url,
int port,
int timeout)
Updates the local time.
|
public static final String NTP_ATTEMPTS_PROPERTY
public static final int NTP_DEFAULT_ATTEMPTS
public static final int NTP_DEFAULT_GUARD_TIME
public static final int NTP_DEFAULT_PORT
public static final String NTP_DEFAULT_SERVER
public static final int NTP_DEFAULT_TIMEOUT
public static final String NTP_GUARD_TIME_PROPERTY
public static final String NTP_PORT_PROPERTY
public static final String NTP_TIMEOUT_PROPERTY
public static final String NTP_URL_PROPERTY
public static void updateLocalTime() throws IOException
IOException
- if an error occurred.public static void updateLocalTime(String url, int port, int timeout) throws IOException
When this method returns, the application time is updated.
url
- the NTP server URL.port
- the NTP server port.timeout
- the timeout for one NTP request.IOException
- if an error occurred.Util.currentTimeMillis()