Top Description Fields Constructors Methods
org.postgresql.util

public Class PGTime

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

This class augments the Java built-in Time 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 time.

private static final long
serialVersionUID

Hides java.sql.Time.serialVersionUID.

The serial version UID.

Constructor Summary

AccessConstructor and Description
public
PGTime(long
milliseconds since January 1, 1970, 00:00:00 GMT; a negative number is milliseconds before January 1, 1970, 00:00:00 GMT.
time
)

Constructs a PGTime without a time zone.

public
PGTime(long
milliseconds since January 1, 1970, 00:00:00 GMT; a negative number is milliseconds before January 1, 1970, 00:00:00 GMT.
time
,
@Nullable Calendar
the calendar object containing the time zone or null.
calendar
)

Constructs a PGTime with the given calendar object.

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 to compare with.
o
)

Overrides java.util.Date.equals.

Compares two dates for equality.

public @Nullable Calendar

Returns:

the calendar or null.
getCalendar
()

Returns the calendar object for this time.

public int
hashCode()

Overrides java.util.Date.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 time.

Inherited from java.sql.Time:
getDategetDaygetMonthgetYearsetDatesetMonthsetTimesetYeartoInstanttoLocalTimetoStringvalueOfvalueOf

Field Detail

calendarback to summary
private @Nullable Calendar calendar

The optional calendar for this time.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.sql.Time.serialVersionUID.

The serial version UID.

Constructor Detail

PGTimeback to summary
public PGTime(long time)

Constructs a PGTime without a time zone.

Parameters
time:long

milliseconds since January 1, 1970, 00:00:00 GMT; a negative number is milliseconds before January 1, 1970, 00:00:00 GMT.

See Also
Time#Time(long)
PGTimeback to summary
public PGTime(long time, @Nullable Calendar calendar)

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

Parameters
time:long

milliseconds since January 1, 1970, 00:00:00 GMT; a negative number is milliseconds before January 1, 1970, 00:00:00 GMT.

calendar:@Nullable Calendar

the calendar object containing the time zone or null.

See Also
Time#Time(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.util.Date.equals.

Doc from java.util.Date.equals.

Compares two dates for equality. The result is true if and only if the argument is not null and is a Date object that represents the same point in time, to the millisecond, as this object.

Thus, two Date objects are equal if and only if the getTime method returns the same long value for both.

Parameters
o:@Nullable Object

the object to compare with.

Returns:boolean

true if the objects are the same; false otherwise.

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

Returns the calendar object for this time.

Returns:@Nullable Calendar

the calendar or null.

hashCodeback to summary
public int hashCode()

Overrides java.util.Date.hashCode.

Doc from java.util.Date.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))
Returns:int

a hash code value for this object.

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

Sets the calendar object for this time.

Parameters
calendar:@Nullable Calendar

the calendar object or null.