- java.lang.Object
-
- eu.ess.xaos.ui.plot.util.Timestamp
-
- All Implemented Interfaces:
Comparable<Timestamp>
public class Timestamp extends Object implements Comparable<Timestamp>
AComparable
timestamp.- Author:
- claudio.rosati@esss.se
-
-
Field Summary
Fields Modifier and Type Field Description protected BigDecimal
timeStamp
The timestamp information in seconds since the Java epoch.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Timestamp other)
Compare this timestamp with another timestamp.boolean
equals(Object timeStamp)
Determine if the given timestamp equals this one.String
format(DateFormat timeFormat)
Generate a string representation of this timestamp using the specified time format for the time format up to seconds.int
hashCode()
Override thehashcode
as required when overriding equals.BigDecimal
toBigDecimal()
Get the time in seconds with full precision since the Java epoch.Date
toDate()
Get the times tamp as a JavaDate
.long
toMilliseconds()
Get the timestamp in milliseconds relative to the Java epoch.double
toSeconds()
Get the time in seconds since the Java epoch.Timestamp
toSQLTimestamp()
Get the SQLTimestamp
equivalent of this instance.String
toString()
Get a string representation of the Timestamp.
-
-
-
Field Detail
-
timeStamp
protected final BigDecimal timeStamp
The timestamp information in seconds since the Java epoch.
-
-
Constructor Detail
-
Timestamp
public Timestamp(BigDecimal timeStamp)
Primary constructor from the full precision seconds since the Java epoch.- Parameters:
timeStamp
- The number of seconds since the Java epoch.
-
Timestamp
public Timestamp(Timestamp source)
Copy constructor.- Parameters:
source
- TheTimestamp
to be copied.
-
Timestamp
public Timestamp(Timestamp timeStamp)
- Parameters:
timeStamp
- The SQL timestamp.
-
-
Method Detail
-
compareTo
public int compareTo(Timestamp other)
Compare this timestamp with another timestamp.- Specified by:
compareTo
in interfaceComparable<Timestamp>
- Parameters:
other
- The timestamp with which to compare this one.- Returns:
- 0 if the timestamps are the same, negative if this is earlier than the supplied one and positive otherwise.
-
equals
public boolean equals(Object timeStamp)
Determine if the given timestamp equals this one.
-
format
public String format(DateFormat timeFormat)
Generate a string representation of this timestamp using the specified time format for the time format up to seconds. Subsecond time is appended using a decimal point.- Parameters:
timeFormat
-DateFormat
used to generate the string up to the subsecond part.- Returns:
- Formatted string representation of this timestamp.
-
hashCode
public int hashCode()
Override thehashcode
as required when overriding equals. Equality implies equality of the underlyingtimeStamp
instance variables.
-
toBigDecimal
public BigDecimal toBigDecimal()
Get the time in seconds with full precision since the Java epoch.- Returns:
- The time in seconds since the Java epoch.
-
toDate
public Date toDate()
Get the times tamp as a JavaDate
. Some precision is lost since the Date class only supports millisecond resolution.- Returns:
- The time stamp as a
Date
object.
-
toMilliseconds
public long toMilliseconds()
Get the timestamp in milliseconds relative to the Java epoch.- Returns:
- The time in milliseconds since the Java epoch.
-
toSQLTimestamp
public Timestamp toSQLTimestamp()
Get the SQLTimestamp
equivalent of this instance.- Returns:
- The SQL
Timestamp
equivalent of this instance.
-
toSeconds
public double toSeconds()
Get the time in seconds since the Java epoch.- Returns:
- The time in seconds since the Java epoch.
-
-