Top Description Fields Constructors Methods
org.jooq.util.postgres

public Class PGInterval

extends PGobject
Class Inheritance
Annotations
@Internal
Imports
java.text.DecimalFormat, .NumberFormat, java.util.Calendar, .Date, .Locale, .StringTokenizer, org.jetbrains.annotations.ApiStatus.Internal

This implements a class that handles the PostgreSQL interval type.

Field Summary

Modifier and TypeField and Description
private int
private int
private boolean
private static final int
private int
private int
private int
private int
private int
Inherited from org.jooq.util.postgres.PGobject:
typevalue

Constructor Summary

AccessConstructor and Description
public
PGInterval()

required by the driver.

public
PGInterval(String
String representated interval (e.g. '3 years 2 mons')
value
)

Initialize a interval with a given interval string representation.

public
PGInterval(int
years
years
,
int
months
months
,
int
days
days
,
int
hours
hours
,
int
minutes
minutes
,
double
seconds
seconds
)

Initializes all values of this interval to the specified values.

Method Summary

Modifier and TypeMethod and Description
public void
add(Calendar
Calendar instance to add to
cal
)

Rolls this interval on a given calendar.

public void
add(Date
Date instance to add to
date
)

Rolls this interval on a given date.

public void
add(PGInterval
intval to add
interval
)

Add this interval's value to the passed interval.

public Object
clone()

Overrides org.jooq.util.postgres.PGobject.clone.

This must be overidden to allow the object to be cloned.
public boolean

Returns:

true if the two intervals are identical
equals
(Object
Object to compare with
obj
)

Overrides org.jooq.util.postgres.PGobject.equals.

Returns whether an object is equal to this one or not.
public int

Returns:

days represented by this interval
getDays
()

Returns the days represented by this interval.

public int

Returns:

hours represented by this interval
getHours
()

Returns the hours represented by this interval.

public int
public int

Returns:

minutes represented by this interval
getMinutes
()

Returns the minutes represented by this interval.

public int

Returns:

months represented by this interval
getMonths
()

Returns the months represented by this interval.

public double

Returns:

seconds represented by this interval
getSeconds
()

Returns the seconds represented by this interval.

public String

Returns:

String represented interval
getValue
()

Overrides org.jooq.util.postgres.PGobject.getValue.

Returns the stored interval information as a string.
public int
public int

Returns:

years represented by this interval
getYears
()

Returns the years represented by this interval.

public int

Returns:

hashCode
hashCode
()

Overrides org.jooq.util.postgres.PGobject.hashCode.

Returns a hashCode for this object.
private int
lookAhead(String value, int position, String find)

private static double

Returns:

double parsed from string value
nullSafeDoubleGet
(String
double as string value
value
)

Returns double value of value or 0 if value is null.

private static int

Returns:

integer parsed from string value
nullSafeIntGet
(String
integer as string value
value
)

Returns integer value of value or 0 if value is null.

private void
public void
scale(int
scale factor
factor
)

Scale this interval by an integer factor.

public void
setDays(int
days to set
days
)

Set the days of this interval to the specified value.

public void
setHours(int
hours to set
hours
)

Set the hours of this interval to the specified value.

public void
setMinutes(int
minutes to set
minutes
)

Set the minutes of this interval to the specified value.

public void
setMonths(int
months to set
months
)

Set the months of this interval to the specified value.

public void
setSeconds(double
seconds to set
seconds
)

Set the seconds of this interval to the specified value.

public void
setValue(String
String representated interval (e.g. '3 years 2 mons')
value
)

Overrides org.jooq.util.postgres.PGobject.setValue.

Sets a interval string represented value to this instance.
public void
setValue(int
years
years
,
int
months
months
,
int
days
days
,
int
hours
hours
,
int
minutes
minutes
,
double
seconds
seconds
)

Set all values of this interval to the specified values.

public void
setYears(int
years to set
years
)

Set the years of this interval to the specified value.

Inherited from org.jooq.util.postgres.PGobject:
equalsgetTypeisNullsetTypetoString

Field Detail

daysback to summary
private int days
hoursback to summary
private int hours
isNullback to summary
private boolean isNull
MICROS_IN_SECONDback to summary
private static final int MICROS_IN_SECOND
microSecondsback to summary
private int microSeconds
minutesback to summary
private int minutes
monthsback to summary
private int months
wholeSecondsback to summary
private int wholeSeconds
yearsback to summary
private int years

Constructor Detail

PGIntervalback to summary
public PGInterval()

required by the driver.

PGIntervalback to summary
public PGInterval(String value)

Initialize a interval with a given interval string representation.

Parameters
value:String

String representated interval (e.g. '3 years 2 mons')

See Also
PGobject#setValue(String)
PGIntervalback to summary
public PGInterval(int years, int months, int days, int hours, int minutes, double seconds)

Initializes all values of this interval to the specified values.

Parameters
years:int

years

months:int

months

days:int

days

hours:int

hours

minutes:int

minutes

seconds:double

seconds

See Also
setValue(int, int, int, int, int, double)

Method Detail

addback to summary
public void add(Calendar cal)

Rolls this interval on a given calendar.

Parameters
cal:Calendar

Calendar instance to add to

addback to summary
public void add(Date date)

Rolls this interval on a given date.

Parameters
date:Date

Date instance to add to

addback to summary
public void add(PGInterval interval)

Add this interval's value to the passed interval. This is backwards to what I would expect, but this makes it match the other existing add methods.

Parameters
interval:PGInterval

intval to add

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides org.jooq.util.postgres.PGobject.clone.

Doc from org.jooq.util.postgres.PGobject.clone.

This must be overidden to allow the object to be cloned.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
Exceptions
CloneNotSupportedException:

Doc from java.lang.Object.clone.

if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

equalsback to summary
public boolean equals(Object obj)

Overrides org.jooq.util.postgres.PGobject.equals.

Returns whether an object is equal to this one or not.

Parameters
obj:Object

Object to compare with

Returns:boolean

true if the two intervals are identical

Annotations
@Override
getDaysback to summary
public int getDays()

Returns the days represented by this interval.

Returns:int

days represented by this interval

getHoursback to summary
public int getHours()

Returns the hours represented by this interval.

Returns:int

hours represented by this interval

getMicroSecondsback to summary
public int getMicroSeconds()
getMinutesback to summary
public int getMinutes()

Returns the minutes represented by this interval.

Returns:int

minutes represented by this interval

getMonthsback to summary
public int getMonths()

Returns the months represented by this interval.

Returns:int

months represented by this interval

getSecondsback to summary
public double getSeconds()

Returns the seconds represented by this interval.

Returns:double

seconds represented by this interval

getValueback to summary
public String getValue()

Overrides org.jooq.util.postgres.PGobject.getValue.

Returns the stored interval information as a string.

Returns:String

String represented interval

Annotations
@Override
getWholeSecondsback to summary
public int getWholeSeconds()
getYearsback to summary
public int getYears()

Returns the years represented by this interval.

Returns:int

years represented by this interval

hashCodeback to summary
public int hashCode()

Overrides org.jooq.util.postgres.PGobject.hashCode.

Returns a hashCode for this object.

Returns:int

hashCode

Annotations
@Override
lookAheadback to summary
private int lookAhead(String value, int position, String find)
nullSafeDoubleGetback to summary
private static double nullSafeDoubleGet(String value) throws NumberFormatException

Returns double value of value or 0 if value is null.

Parameters
value:String

double as string value

Returns:double

double parsed from string value

Exceptions
NumberFormatException:
if the string contains invalid chars
nullSafeIntGetback to summary
private static int nullSafeIntGet(String value) throws NumberFormatException

Returns integer value of value or 0 if value is null.

Parameters
value:String

integer as string value

Returns:int

integer parsed from string value

Exceptions
NumberFormatException:
if the string contains invalid chars
parseISO8601Formatback to summary
private void parseISO8601Format(String value)
scaleback to summary
public void scale(int factor)

Scale this interval by an integer factor. The server can scale by arbitrary factors, but that would require adjusting the call signatures for all the existing methods like getDays() or providing our own justification of fractional intervals. Neither of these seem like a good idea without a strong use case.

Parameters
factor:int

scale factor

setDaysback to summary
public void setDays(int days)

Set the days of this interval to the specified value.

Parameters
days:int

days to set

setHoursback to summary
public void setHours(int hours)

Set the hours of this interval to the specified value.

Parameters
hours:int

hours to set

setMinutesback to summary
public void setMinutes(int minutes)

Set the minutes of this interval to the specified value.

Parameters
minutes:int

minutes to set

setMonthsback to summary
public void setMonths(int months)

Set the months of this interval to the specified value.

Parameters
months:int

months to set

setSecondsback to summary
public void setSeconds(double seconds)

Set the seconds of this interval to the specified value.

Parameters
seconds:double

seconds to set

setValueback to summary
public void setValue(String value)

Overrides org.jooq.util.postgres.PGobject.setValue.

Sets a interval string represented value to this instance. This method only recognize the format, that Postgres returns - not all input formats are supported (e.g. '1 yr 2 m 3 s').

Parameters
value:String

String representated interval (e.g. '3 years 2 mons')

Annotations
@Override
setValueback to summary
public void setValue(int years, int months, int days, int hours, int minutes, double seconds)

Set all values of this interval to the specified values.

Parameters
years:int

years

months:int

months

days:int

days

hours:int

hours

minutes:int

minutes

seconds:double

seconds

setYearsback to summary
public void setYears(int years)

Set the years of this interval to the specified value.

Parameters
years:int

years to set