public class NtpTimeStamp
extends java.lang.Object
implements java.lang.Comparable
Since only 32 bits are used for the integer part, February 7, 2036, at 6h:28m:15s
is the last absolute time returned by the method getTime(), while at 6h:28m:16s
it wraps and go back to January 1, 1900.
In order to have a longer absolute period, the time returned by method getTime() is
within the interval from January 20, 1968, at 4h:14m:8s GMT,
until February 26, 2014, at 9h:42m:23s GMT.
However, for RTP purposes, only differences between pairs of NTP timestamps are used. So long as the pairs of timestamps can be assumed to be within 68 years of each other, using modular arithmetic for subtractions and comparisons makes the wraparound irrelevant.
The Network Time Protocol and the timestamp format are defined in RFC 1305 (Network Time Protocol (Version 3) Specification, Implementation and Analysis), and RFC 2030 (Simple Network Time Protocol (SNTP) Version 4 for IPv4, IPv6 and OSI).
Modifier and Type | Field and Description |
---|---|
static long |
NTP_TIME_0
NTP time 0 (Jan 1, 1900), in Java time format (that is from January 1, 1970)
|
Constructor and Description |
---|
NtpTimeStamp(long time)
Creates a new NtpTimeStamp.
|
NtpTimeStamp(long seconds,
long fraction)
Creates a new NtpTimeStamp.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object obj)
From interface Comparable.
|
boolean |
equals(java.lang.Object obj)
Whether it is equal to the specified object.
|
long |
getNtpFraction()
Gets the fractional part of NTP seconds.
|
long |
getNtpSeconds()
Gets the integer part of NTP seconds.
|
long |
getNtpTime()
Gets the NTP timestamp time (in NTP format).
|
long |
getTime()
Gets the timestamp time (in Java format, thati is from Java epoch time January 1, 1970).
|
java.lang.String |
toString()
Gets a string representation of this object.
|
public static final long NTP_TIME_0
public NtpTimeStamp(long seconds, long fraction)
seconds
- the integer part of NTP seconds (in NTP format, that is from January 1, 1900)fraction
- the fractional part of NTP seconds (in NTP format, that is from January 1, 1900)public NtpTimeStamp(long time)
time
- the timestamp time value (in Java format, that is from Java epoch time January 1, 1970)public long getNtpTime()
public long getNtpSeconds()
public long getNtpFraction()
public long getTime()
public int compareTo(java.lang.Object obj) throws java.lang.ClassCastException
compareTo
in interface java.lang.Comparable
obj
- the Object to be comparedjava.lang.ClassCastException
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the Object to be comparedpublic java.lang.String toString()
toString
in class java.lang.Object