Package org.postgresql.util
Class PGTimestamp
- java.lang.Object
-
- java.util.Date
-
- java.sql.Timestamp
-
- org.postgresql.util.PGTimestamp
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<java.util.Date>
public class PGTimestamp extends java.sql.TimestampThis class augments the Java built-in Timestamp to allow for explicit setting of the time zone.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.CalendarcalendarThe optional calendar for this timestamp.private static longserialVersionUIDThe serial version UID.
-
Constructor Summary
Constructors Constructor Description PGTimestamp(long time)Constructs aPGTimestampwithout a time zone.PGTimestamp(long time, java.util.Calendar calendar)Constructs aPGTimestampwith the given time zone.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()booleanequals(java.lang.Object o)java.util.CalendargetCalendar()Returns the calendar object for this timestamp.inthashCode()voidsetCalendar(java.util.Calendar calendar)Sets the calendar object for this timestamp.-
Methods inherited from class java.sql.Timestamp
after, before, compareTo, compareTo, equals, from, getNanos, getTime, setNanos, setTime, toInstant, toLocalDateTime, toString, valueOf, valueOf
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
The serial version UID.- See Also:
- Constant Field Values
-
calendar
private java.util.Calendar calendar
The optional calendar for this timestamp.
-
-
Constructor Detail
-
PGTimestamp
public PGTimestamp(long time)
Constructs aPGTimestampwithout a time zone. The integral seconds are stored in the underlying date value; the fractional seconds are stored in thenanosfield of theTimestampobject.- 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:
Timestamp(long)
-
PGTimestamp
public PGTimestamp(long time, java.util.Calendar calendar)Constructs a
PGTimestampwith the given time zone. The integral seconds are stored in the underlying date value; the fractional seconds are stored in thenanosfield of theTimestampobject.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 atimestamp with time zoneusing theTimeZonein the calendar object. Furthermore, this calendar will be used instead of the calendar object passed toPreparedStatement.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 ornull.- See Also:
Timestamp(long)
-
-
Method Detail
-
setCalendar
public void setCalendar(java.util.Calendar calendar)
Sets the calendar object for this timestamp.- Parameters:
calendar- the calendar object ornull.
-
getCalendar
public java.util.Calendar getCalendar()
Returns the calendar object for this timestamp.- Returns:
- the calendar object or
null.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.sql.Timestamp
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.sql.Timestamp
-
clone
public java.lang.Object clone()
- Overrides:
clonein classjava.util.Date
-
-