public final class Timestamp extends Object implements ITimestamp
ITimestamp interface.ITimestamp.Format| Modifier and Type | Field and Description |
|---|---|
static long |
MILLIS_PER_SECOND
Milliseconds per second.
|
static long |
NANOS_PER_MILLI
Nanoseconds per millisecond.
|
static long |
NANOS_PER_SECOND
Nanoseconds per second.
|
| Constructor and Description |
|---|
Timestamp(double seconds)
Constructor with fractional seconds since epoch.
|
Timestamp(long seconds,
long nanoseconds)
Constructor with seconds and nanoseconds since epoch.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(ITimestamp rhs) |
boolean |
equals(Object obj) |
String |
format(ITimestamp.Format format)
Format time according to the given format.
|
int |
hashCode() |
boolean |
isGreaterOrEqual(ITimestamp other) |
boolean |
isGreaterThan(ITimestamp other) |
boolean |
isLessOrEqual(ITimestamp other) |
boolean |
isLessThan(ITimestamp other) |
boolean |
isValid() |
long |
nanoseconds()
Nanoseconds within seconds.
|
long |
seconds()
Get seconds since epoch, i.e.
|
Calendar |
toCalendar()
Convert to Calendar.
|
double |
toDouble()
Convert to double.
|
String |
toString() |
public static final long MILLIS_PER_SECOND
public static final long NANOS_PER_MILLI
public static final long NANOS_PER_SECOND
public Timestamp(long seconds,
long nanoseconds)
seconds - Seconds since epochnanoseconds - Nanoseconds within secondspublic Timestamp(double seconds)
seconds - Seconds since epochpublic long seconds()
ITimestampNote that we always return seconds relative to this UTC epoch, even if the original control system data source might use a different epoch (example: EPICS uses 1990), because the 1970 epoch is most compatible with existing programming environments.
seconds in interface ITimestamppublic long nanoseconds()
ITimestampnanoseconds in interface ITimestampITimestamp.seconds()public boolean isValid()
isValid in interface ITimestamptrue if seconds and nanoseconds are > 0.public double toDouble()
ITimestamptoDouble in interface ITimestamppublic Calendar toCalendar()
ITimestamptoCalendar in interface ITimestamppublic String format(ITimestamp.Format format)
ITimestampformat in interface ITimestampformat - format to usepublic boolean isGreaterThan(ITimestamp other)
isGreaterThan in interface ITimestampother - Other time stamptrue if this time stamp is greater than the other time stamp.public boolean isGreaterOrEqual(ITimestamp other)
isGreaterOrEqual in interface ITimestampother - Other time stamptrue if this time stamp is greater than or equal to the other time
stamp.public boolean isLessThan(ITimestamp other)
isLessThan in interface ITimestampother - Other time stamptrue if this time stamp is smaller than the other time stamp.public boolean isLessOrEqual(ITimestamp other)
isLessOrEqual in interface ITimestampother - Other time stamptrue if this time stamp is smaller than or equal to the other time
stamp.public int compareTo(ITimestamp rhs)
compareTo in interface Comparable<ITimestamp>Copyright © 2023 European Spallation Source. All rights reserved.