public interface ITimestamp extends Comparable<ITimestamp>
Java already supports many time-stamp related operations via the Calendar class down to milliseconds,
but control system time stamps often include micro or nanosecond detail.
This time stamp uses 'seconds' with the same epoch as Calendar (1 January 1970 0:00 UTC), and adds nanosecond detail.
In addition, it supports comparisons as well as string conversions to the form yyyy/mm/dd HH:MM:SS.MMM,
for example 2007/01/15 14:45:56.123, which sorts well and is disambiguated from regional preferences
like AM/PM formats, or day/month/year vs. month/day/year.
Calendar,
TimestampFactory| Modifier and Type | Interface and Description |
|---|---|
static class |
ITimestamp.Format
Format specifier.
|
| Modifier and Type | Method and Description |
|---|---|
String |
format(ITimestamp.Format format)
Format time according to the given format.
|
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.
|
compareTolong seconds()
Note 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.
long nanoseconds()
seconds()boolean isValid()
true if seconds and nanoseconds are > 0.double toDouble()
Calendar toCalendar()
String format(ITimestamp.Format format)
format - format to useboolean isGreaterThan(ITimestamp other)
other - Other time stamptrue if this time stamp is greater than the other time stamp.boolean isGreaterOrEqual(ITimestamp other)
other - Other time stamptrue if this time stamp is greater than or equal to the other time
stamp.boolean isLessThan(ITimestamp other)
other - Other time stamptrue if this time stamp is smaller than the other time stamp.boolean isLessOrEqual(ITimestamp other)
other - Other time stamptrue if this time stamp is smaller than or equal to the other time
stamp.Copyright © 2023 European Spallation Source. All rights reserved.