Package xal.ca

Class Timestamp

java.lang.Object
xal.ca.Timestamp
All Implemented Interfaces:
Comparable<Timestamp>

public class Timestamp extends Object implements Comparable<Timestamp>
Timestamp
Author:
tap
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected BigDecimal
    the timestamp information
  • Constructor Summary

    Constructors
    Constructor
    Description
    Timestamp(BigDecimal timestamp)
    Primary constructor from the full precision seconds since the Java epoch.
    Timestamp(Timestamp timestamp)
    Construct a Timestamp from a java.sql.Timestamp
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    compareTo(Timestamp otherTimestamp)
    Compare this timestamp with another timestamp.
    boolean
    equals(Object timestamp)
    Determine if the specified timestamp equals this one.
    Get the times tamp as a Java Date.
    Get the time in seconds with full precision since the Java epoch.
    double
    Get the time in seconds since the Java epoch.
    Get the SQL Timestamp equivalent of this instance.
    long
    Get the timestamp in milliseconds relative to the Java epoch.
    int
    Override the hashcode as required when overriding equals.
    Get a string representation of the Timestamp.
    toString(DateFormat timeFormat)
    Generate a string representation of this timestamp using the specified time format for the time format up to seconds.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • timestampBD

      protected BigDecimal timestampBD
      the timestamp information
  • Constructor Details

    • 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 timestamp)
      Construct a Timestamp from a java.sql.Timestamp
      Parameters:
      timestamp - an SQL timestamp
  • Method Details

    • getDate

      public Date getDate()
      Get the times tamp as a Java Date. Some precision is lost since the Date class only supports millisecond resolution.
      Returns:
      The time stamp as a Date.
    • getTime

      public long getTime()
      Get the timestamp in milliseconds relative to the Java epoch.
      Returns:
      The time in milliseconds since the Java epoch.
    • getSeconds

      public double getSeconds()
      Get the time in seconds since the Java epoch.
      Returns:
      the time in seconds since the Java epoch.
    • getFullSeconds

      public BigDecimal getFullSeconds()
      Get the time in seconds with full precision since the Java epoch.
      Returns:
      the time in seconds since the Java epoch.
    • getSQLTimestamp

      public Timestamp getSQLTimestamp()
      Get the SQL Timestamp equivalent of this instance.
      Returns:
      the SQL Timestamp equivalent of this instance.
    • toString

      public String toString(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 - format for which to generate the string
      Returns:
      formatted string representation
    • toString

      public String toString()
      Get a string representation of the Timestamp.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the Timestamp
    • equals

      public boolean equals(Object timestamp)
      Determine if the specified timestamp equals this one.
      Overrides:
      equals in class Object
      Returns:
      true if they are equals and false if not
    • hashCode

      public int hashCode()
      Override the hashcode as required when overriding equals. Equality implies equality of the underlying timestamp instance variables.
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(Timestamp otherTimestamp)
      Compare this timestamp with another timestamp.
      Specified by:
      compareTo in interface Comparable<Timestamp>
      Parameters:
      otherTimestamp - 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