Class PGTimestamp

java.lang.Object
java.util.Date
java.sql.Timestamp
org.postgresql.util.PGTimestamp
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Date>

public class PGTimestamp extends Timestamp
This class augments the Java built-in Timestamp to allow for explicit setting of the time zone.
See Also:
  • Constructor Details

    • PGTimestamp

      public PGTimestamp(long time)
      Constructs a PGTimestamp without a time zone. The integral seconds are stored in the underlying date value; the fractional seconds are stored in the nanos field of the Timestamp object.
      Parameters:
      time - milliseconds since January 1, 1970, 00:00:00 GMT. A negative number is the number of milliseconds before January 1, 1970, 00:00:00 GMT.
      See Also:
    • PGTimestamp

      public PGTimestamp(long time, @Nullable Calendar calendar)

      Constructs a PGTimestamp with the given time zone. The integral seconds are stored in the underlying date value; the fractional seconds are stored in the nanos field of the Timestamp object.

      The calendar object is optional. If absent, the driver will treat the timestamp as timestamp without time zone. When present, the driver will treat the timestamp as a timestamp with time zone using the TimeZone in the calendar object. Furthermore, this calendar will be used instead of the calendar object passed to PreparedStatement.setTimestamp(int, Timestamp, Calendar).

      Parameters:
      time - milliseconds since January 1, 1970, 00:00:00 GMT. A negative number is the number of milliseconds before January 1, 1970, 00:00:00 GMT.
      calendar - the calendar object containing the time zone or null.
      See Also:
  • Method Details

    • setCalendar

      public void setCalendar(@Nullable Calendar calendar)
      Sets the calendar object for this timestamp.
      Parameters:
      calendar - the calendar object or null.
    • getCalendar

      public @Nullable Calendar getCalendar()
      Returns the calendar object for this timestamp.
      Returns:
      the calendar object or null.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Timestamp
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Timestamp
    • clone

      public Object clone()
      Overrides:
      clone in class Date