org.csstudio.data.values
Interface ITimestamp

All Superinterfaces:
java.lang.Comparable<ITimestamp>, java.io.Serializable

public interface ITimestamp
extends java.lang.Comparable<ITimestamp>, java.io.Serializable

A control system time stamp.

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.

Author:
Sven Wende, Kay Kasemir
See Also:
Calendar, TimestampFactory

Nested Class Summary
static class ITimestamp.Format
          Format specifier.
 
Method Summary
 java.lang.String format(ITimestamp.Format format)
          Format time according to the FMT_...
 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.
 java.util.Calendar toCalendar()
          Convert to Calendar.
 double toDouble()
          Convert to double.
 java.sql.Timestamp toSQLTimestamp()
          Convert to SQL Timestamp.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

seconds

long seconds()
Get seconds since epoch, i.e. 1 January 1970 0:00 UTC.

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.

Returns:
Seconds since 1970.

nanoseconds

long nanoseconds()
Nanoseconds within seconds.

Returns:
The nanoseconds, 0...999999999.
See Also:
seconds()

isValid

boolean isValid()
Returns:
Returns true if seconds and nanoseconds are > 0.

toDouble

double toDouble()
Convert to double.

Returns:
Return seconds and fractional nanoseconds.

toCalendar

java.util.Calendar toCalendar()
Convert to Calendar.

Returns:
Calendar version of this time stamp down to millisecond detail.

toSQLTimestamp

java.sql.Timestamp toSQLTimestamp()
Convert to SQL Timestamp.

Returns:
SQL Timestamp

format

java.lang.String format(ITimestamp.Format format)
Format time according to the FMT_... flag.

Parameters:
how - One of the FMT_... flags.
Returns:
The formatted time.

isGreaterThan

boolean isGreaterThan(ITimestamp other)
Parameters:
other - Other time stamp
Returns:
Returns true if this time stamp is greater than the other time stamp.

isGreaterOrEqual

boolean isGreaterOrEqual(ITimestamp other)
Parameters:
other - Other time stamp
Returns:
Returns true if this time stamp is greater than or equal to the other time stamp.

isLessThan

boolean isLessThan(ITimestamp other)
Parameters:
other - Other time stamp
Returns:
Returns true if this time stamp is smaller than the other time stamp.

isLessOrEqual

boolean isLessOrEqual(ITimestamp other)
Parameters:
other - Other time stamp
Returns:
Returns true if this time stamp is smaller than or equal to the other time stamp.