Utility class to assist with Network Time Protocol (NTP) conversions. More...
Public Member Functions | |
java.util.Date | compactNtpToDateTime (long ntp) |
Converts a compact NTP timestamp (32 bits) to a date. More... | |
long | compactNtpToTicks (long ntp) |
Converts a compact NTP timestamp (32 bits) to ticks. More... | |
long | dateTimeToCompactNtp (java.util.Date dateTime) |
Converts a date to a compact NTP timestamp (32 bits). More... | |
long | dateTimeToNtp (java.util.Date dateTime) |
Converts a date to an NTP timestamp (64 bits). More... | |
double | dateTimeToNtpSeconds (java.util.Date dateTime) |
Converts a date to an NTP timestamp (double). More... | |
long | getUtcNow () |
Gets the current UTC time in NTP format. More... | |
NetworkTimeProtocol () | |
Initializes a new instance of the fm.liveswitch.NetworkTimeProtocol class with base set to 1900-01-01. More... | |
NetworkTimeProtocol (long baseTicks) | |
Initializes a new instance of the fm.liveswitch.NetworkTimeProtocol class. More... | |
java.util.Date | ntpSecondsToDateTime (double ntpSeconds) |
Converts an NTP timestamp (double) to a date. More... | |
long | ntpSecondsToTicks (double ntpSeconds) |
Converts an NTP timestamp (double) to ticks. More... | |
java.util.Date | ntpToDateTime (long ntp) |
Converts an NTP timestamp (64 bits) to a date. More... | |
long | ntpToTicks (long ntp) |
Converts an NTP timestamp (64 bits) to ticks. More... | |
long | ticksToCompactNtp (long ticks) |
Converts ticks to a compact NTP timestamp (32 bits). More... | |
long | ticksToNtp (long ticks) |
Converts ticks to an NTP timestamp (64 bits). More... | |
double | ticksToNtpSeconds (long ticks) |
Converts ticks to an NTP timestamp (double). More... | |
Static Public Member Functions | |
static fm.liveswitch.NetworkTimeProtocol | getAbsolute () |
Gets an instance of fm.liveswitch.NetworkTimeProtocol that uses 1900-01-01 as the reference date, for use cases where the absolute wall-clock time represented is important. More... | |
static fm.liveswitch.NetworkTimeProtocol | getRelative () |
Gets an instance of fm.liveswitch.NetworkTimeProtocol that uses zero as the reference date, for use cases where the time is relative to other times, and the reference time is not significant. More... | |
Utility class to assist with Network Time Protocol (NTP) conversions.
NTP timestamps are 64-bit values that can span just over 136 years, from 1900-01-01 to 2036-02-08. Compact NTP timestamps are 32-bit values that can span span just over 18 hours. These utility methods guarantee precision to the millisecond.
fm.liveswitch.NetworkTimeProtocol.NetworkTimeProtocol | ( | ) |
Initializes a new instance of the fm.liveswitch.NetworkTimeProtocol class with base set to 1900-01-01.
fm.liveswitch.NetworkTimeProtocol.NetworkTimeProtocol | ( | long | baseTicks | ) |
Initializes a new instance of the fm.liveswitch.NetworkTimeProtocol class.
baseTicks | The base ticks. |
java.util.Date fm.liveswitch.NetworkTimeProtocol.compactNtpToDateTime | ( | long | ntp | ) |
Converts a compact NTP timestamp (32 bits) to a date.
ntp | The NTP timestamp to convert. |
long fm.liveswitch.NetworkTimeProtocol.compactNtpToTicks | ( | long | ntp | ) |
Converts a compact NTP timestamp (32 bits) to ticks.
ntp | The NTP timestamp to convert. |
long fm.liveswitch.NetworkTimeProtocol.dateTimeToCompactNtp | ( | java.util.Date | dateTime | ) |
Converts a date to a compact NTP timestamp (32 bits).
dateTime | The date to convert. |
long fm.liveswitch.NetworkTimeProtocol.dateTimeToNtp | ( | java.util.Date | dateTime | ) |
Converts a date to an NTP timestamp (64 bits).
dateTime | The date to convert. |
double fm.liveswitch.NetworkTimeProtocol.dateTimeToNtpSeconds | ( | java.util.Date | dateTime | ) |
Converts a date to an NTP timestamp (double).
dateTime | The date to convert. |
|
static |
Gets an instance of fm.liveswitch.NetworkTimeProtocol that uses 1900-01-01 as the reference date, for use cases where the absolute wall-clock time represented is important.
|
static |
Gets an instance of fm.liveswitch.NetworkTimeProtocol that uses zero as the reference date, for use cases where the time is relative to other times, and the reference time is not significant.
long fm.liveswitch.NetworkTimeProtocol.getUtcNow | ( | ) |
Gets the current UTC time in NTP format.
java.util.Date fm.liveswitch.NetworkTimeProtocol.ntpSecondsToDateTime | ( | double | ntpSeconds | ) |
Converts an NTP timestamp (double) to a date.
ntpSeconds | The NTP timestamp to convert. |
long fm.liveswitch.NetworkTimeProtocol.ntpSecondsToTicks | ( | double | ntpSeconds | ) |
Converts an NTP timestamp (double) to ticks.
ntpSeconds | The NTP timestamp to convert. |
java.util.Date fm.liveswitch.NetworkTimeProtocol.ntpToDateTime | ( | long | ntp | ) |
Converts an NTP timestamp (64 bits) to a date.
ntp | The NTP timestamp to convert. |
long fm.liveswitch.NetworkTimeProtocol.ntpToTicks | ( | long | ntp | ) |
Converts an NTP timestamp (64 bits) to ticks.
ntp | The NTP timestamp to convert. |
long fm.liveswitch.NetworkTimeProtocol.ticksToCompactNtp | ( | long | ticks | ) |
Converts ticks to a compact NTP timestamp (32 bits).
ticks | The ticks to convert. |
long fm.liveswitch.NetworkTimeProtocol.ticksToNtp | ( | long | ticks | ) |
Converts ticks to an NTP timestamp (64 bits).
ticks | The ticks to convert. |
double fm.liveswitch.NetworkTimeProtocol.ticksToNtpSeconds | ( | long | ticks | ) |
Converts ticks to an NTP timestamp (double).
ticks | The ticks to convert. |