Top Description Fields Constructors Methods
org.postgresql.util

public Class PGTimestamp

extends Timestamp
Class Inheritance
Imports
org.checkerframework.checker.nullness.qual.Nullable, java.sql.Timestamp, java.util.Calendar

This class augments the Java built-in Timestamp to allow for explicit setting of the time zone.

Field Summary

Modifier and TypeField and Description
private @Nullable Calendar
calendar

The optional calendar for this timestamp.

private static final long

Constructor Summary

AccessConstructor and Description
public
PGTimestamp(long
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.
time
)

Constructs a PGTimestamp without a time zone.

public
PGTimestamp(long
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.
time
,
@Nullable Calendar
the calendar object containing the time zone or null.
calendar
)

Constructs a PGTimestamp with the given time zone.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.util.Date.clone.

Return a copy of this object.

public boolean
equals(@Nullable Object
the Object value to compare with
o
)

Overrides java.sql.Timestamp.equals.

Tests to see if this Timestamp object is equal to the given object.

public @Nullable Calendar

Returns:

the calendar object or null.
getCalendar
()

Returns the calendar object for this timestamp.

public int
hashCode()

Overrides java.sql.Timestamp.hashCode.

Returns a hash code value for this object.

public void
setCalendar(@Nullable Calendar
the calendar object or null.
calendar
)

Sets the calendar object for this timestamp.

Inherited from java.sql.Timestamp:
afterbeforecompareTocompareToequalsfromgetNanosgetTimesetNanossetTimetoInstanttoLocalDateTimetoStringvalueOfvalueOf

Field Detail

calendarback to summary
private @Nullable Calendar calendar

The optional calendar for this timestamp.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.sql.Timestamp.serialVersionUID.

The serial version UID.

Constructor Detail

PGTimestampback to summary
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:long

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#Timestamp(long)
PGTimestampback to summary
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 java.sql.PreparedStatement#setTimestamp(int, Timestamp, Calendar).

Parameters
time:long

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:@Nullable Calendar

the calendar object containing the time zone or null.

See Also
Timestamp#Timestamp(long)

Method Detail

cloneback to summary
public Object clone()

Overrides java.util.Date.clone.

Doc from java.util.Date.clone.

Return a copy of this object.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
equalsback to summary
public boolean equals(@Nullable Object o)

Overrides java.sql.Timestamp.equals.

Doc from java.sql.Timestamp.equals.

Tests to see if this Timestamp object is equal to the given object. This version of the method equals has been added to fix the incorrect signature of Timestamp.equals(Timestamp) and to preserve backward compatibility with existing class files.

Note

This method is not symmetric with respect to the equals(Object) method in the base class.

Parameters
o:@Nullable Object

the Object value to compare with

Returns:boolean

true if the given Object is an instance of a Timestamp that is equal to this Timestamp object; false otherwise

Annotations
@Override
getCalendarback to summary
public @Nullable Calendar getCalendar()

Returns the calendar object for this timestamp.

Returns:@Nullable Calendar

the calendar object or null.

hashCodeback to summary
public int hashCode()

Overrides java.sql.Timestamp.hashCode.

Doc from java.sql.Timestamp.hashCode.

Returns a hash code value for this object. The result is the exclusive OR of the two halves of the primitive long value returned by the Date#getTime method. That is, the hash code is the value of the expression:

(int)(this.getTime()^(this.getTime() >>> 32))
The hashCode method uses the underlying java.util.Date implementation and therefore does not include nanos in its computation.
Returns:int

Doc from java.util.Date.hashCode.

a hash code value for this object.

Annotations
@Override
setCalendarback to summary
public void setCalendar(@Nullable Calendar calendar)

Sets the calendar object for this timestamp.

Parameters
calendar:@Nullable Calendar

the calendar object or null.