public class PGInterval extends PGobject implements java.io.Serializable, java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
private int |
days |
private int |
hours |
private static int |
MICROS_IN_SECOND |
private int |
microSeconds |
private int |
minutes |
private int |
months |
private int |
wholeSeconds |
private int |
years |
Constructor and Description |
---|
PGInterval()
required by the driver.
|
PGInterval(int years,
int months,
int days,
int hours,
int minutes,
double seconds)
Initializes all values of this interval to the specified values.
|
PGInterval(java.lang.String value)
Initialize a interval with a given interval string representation.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.util.Calendar cal)
Rolls this interval on a given calendar.
|
void |
add(java.util.Date date)
Rolls this interval on a given date.
|
void |
add(PGInterval interval)
Add this interval's value to the passed interval.
|
java.lang.Object |
clone()
This must be overidden to allow the object to be cloned.
|
boolean |
equals(java.lang.Object obj)
Returns whether an object is equal to this one or not.
|
int |
getDays()
Returns the days represented by this interval.
|
int |
getHours()
Returns the hours represented by this interval.
|
int |
getMicroSeconds() |
int |
getMinutes()
Returns the minutes represented by this interval.
|
int |
getMonths()
Returns the months represented by this interval.
|
double |
getSeconds()
Returns the seconds represented by this interval.
|
java.lang.String |
getValue()
Returns the stored interval information as a string.
|
int |
getWholeSeconds() |
int |
getYears()
Returns the years represented by this interval.
|
int |
hashCode()
Returns a hashCode for this object.
|
private int |
lookAhead(java.lang.String value,
int position,
java.lang.String find) |
private static double |
nullSafeDoubleGet(java.lang.String value)
Returns double value of value or 0 if value is null.
|
private static int |
nullSafeIntGet(java.lang.String value)
Returns integer value of value or 0 if value is null.
|
private void |
parseISO8601Format(java.lang.String value) |
void |
scale(int factor)
Scale this interval by an integer factor.
|
void |
setDays(int days)
Set the days of this interval to the specified value.
|
void |
setHours(int hours)
Set the hours of this interval to the specified value.
|
void |
setMinutes(int minutes)
Set the minutes of this interval to the specified value.
|
void |
setMonths(int months)
Set the months of this interval to the specified value.
|
void |
setSeconds(double seconds)
Set the seconds of this interval to the specified value.
|
void |
setValue(int years,
int months,
int days,
int hours,
int minutes,
double seconds)
Set all values of this interval to the specified values.
|
void |
setValue(java.lang.String value)
Sets a interval string represented value to this instance.
|
void |
setYears(int years)
Set the years of this interval to the specified value.
|
private static final int MICROS_IN_SECOND
private int years
private int months
private int days
private int hours
private int minutes
private int wholeSeconds
private int microSeconds
public PGInterval()
public PGInterval(java.lang.String value) throws java.sql.SQLException
value
- String representated interval (e.g. '3 years 2 mons')java.sql.SQLException
- Is thrown if the string representation has an unknown formatsetValue(String)
public PGInterval(int years, int months, int days, int hours, int minutes, double seconds)
years
- yearsmonths
- monthsdays
- dayshours
- hoursminutes
- minutesseconds
- secondssetValue(int, int, int, int, int, double)
private int lookAhead(java.lang.String value, int position, java.lang.String find)
private void parseISO8601Format(java.lang.String value)
public void setValue(java.lang.String value) throws java.sql.SQLException
public void setValue(int years, int months, int days, int hours, int minutes, double seconds)
years
- yearsmonths
- monthsdays
- dayshours
- hoursminutes
- minutesseconds
- secondspublic java.lang.String getValue()
public int getYears()
public void setYears(int years)
years
- years to setpublic int getMonths()
public void setMonths(int months)
months
- months to setpublic int getDays()
public void setDays(int days)
days
- days to setpublic int getHours()
public void setHours(int hours)
hours
- hours to setpublic int getMinutes()
public void setMinutes(int minutes)
minutes
- minutes to setpublic double getSeconds()
public int getWholeSeconds()
public int getMicroSeconds()
public void setSeconds(double seconds)
seconds
- seconds to setpublic void add(java.util.Calendar cal)
cal
- Calendar instance to add topublic void add(java.util.Date date)
date
- Date instance to add topublic void add(PGInterval interval)
interval
- intval to addpublic void scale(int factor)
factor
- scale factorprivate static int nullSafeIntGet(java.lang.String value) throws java.lang.NumberFormatException
value
- integer as string valuejava.lang.NumberFormatException
- if the string contains invalid charsprivate static double nullSafeDoubleGet(java.lang.String value) throws java.lang.NumberFormatException
value
- double as string valuejava.lang.NumberFormatException
- if the string contains invalid charspublic boolean equals(java.lang.Object obj)
public int hashCode()