public final class Interval
extends java.lang.Object
Constructor and Description |
---|
Interval(IntervalQualifier qualifier,
boolean negative,
long leading,
long remaining)
Creates a new interval.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
long |
getDays()
Returns days value, if any.
|
long |
getHours()
Returns hours value, if any.
|
long |
getLeading()
Returns value of leading field of this interval.
|
long |
getMinutes()
Returns minutes value, if any.
|
long |
getMonths()
Returns months value, if any.
|
long |
getNanosOfSecond()
Returns value of fractional part of seconds (in nanoseconds), if any.
|
IntervalQualifier |
getQualifier()
Returns qualifier of this interval.
|
long |
getRemaining()
Returns combined value of remaining fields of this interval.
|
long |
getSeconds()
Returns value of integer part of seconds, if any.
|
long |
getSecondsAndNanos()
Returns seconds value measured in nanoseconds, if any.
|
long |
getYears()
Returns years value, if any.
|
int |
hashCode() |
boolean |
isNegative()
Returns where the interval is negative.
|
static Interval |
ofDays(long days)
Creates a new INTERVAL DAY.
|
static Interval |
ofDaysHours(long days,
int hours)
Creates a new INTERVAL DAY TO HOUR.
|
static Interval |
ofDaysHoursMinutes(long days,
int hours,
int minutes)
Creates a new INTERVAL DAY TO MINUTE.
|
static Interval |
ofDaysHoursMinutesNanos(long days,
int hours,
int minutes,
long nanos)
Creates a new INTERVAL DAY TO SECOND.
|
static Interval |
ofDaysHoursMinutesSeconds(long days,
int hours,
int minutes,
int seconds)
Creates a new INTERVAL DAY TO SECOND.
|
static Interval |
ofHours(long hours)
Creates a new INTERVAL HOUR.
|
static Interval |
ofHoursMinutes(long hours,
int minutes)
Creates a new INTERVAL HOUR TO MINUTE.
|
static Interval |
ofHoursMinutesNanos(long hours,
int minutes,
long nanos)
Creates a new INTERVAL HOUR TO SECOND.
|
static Interval |
ofHoursMinutesSeconds(long hours,
int minutes,
int seconds)
Creates a new INTERVAL HOUR TO SECOND.
|
static Interval |
ofMinutes(long minutes)
Creates a new INTERVAL MINUTE.
|
static Interval |
ofMinutesNanos(long minutes,
long nanos)
Creates a new INTERVAL MINUTE TO SECOND.
|
static Interval |
ofMinutesSeconds(long minutes,
int seconds)
Creates a new INTERVAL MINUTE TO SECOND.
|
static Interval |
ofMonths(long months)
Creates a new INTERVAL MONTH.
|
static Interval |
ofNanos(long nanos)
Creates a new INTERVAL SECOND.
|
static Interval |
ofSeconds(long seconds)
Creates a new INTERVAL SECOND.
|
static Interval |
ofSeconds(long seconds,
int nanos)
Creates a new INTERVAL SECOND.
|
static Interval |
ofYears(long years)
Creates a new INTERVAL YEAR.
|
static Interval |
ofYearsMonths(long years,
int months)
Creates a new INTERVAL YEAR TO MONTH.
|
java.lang.String |
toString() |
public Interval(IntervalQualifier qualifier, boolean negative, long leading, long remaining)
qualifier
- qualifiernegative
- whether interval is negativeleading
- value of leading fieldremaining
- combined value of all remaining fieldspublic static Interval ofYears(long years)
years
- years, |years|<1018public static Interval ofMonths(long months)
months
- months, |months|<1018public static Interval ofDays(long days)
days
- days, |days|<1018public static Interval ofHours(long hours)
hours
- hours, |hours|<1018public static Interval ofMinutes(long minutes)
minutes
- minutes, |minutes|<1018public static Interval ofSeconds(long seconds)
seconds
- seconds, |seconds|<1018public static Interval ofSeconds(long seconds, int nanos)
If both arguments are not equal to zero they should have the same sign.
seconds
- seconds, |seconds|<1018nanos
- nanoseconds, |nanos|<1,000,000,000public static Interval ofNanos(long nanos)
nanos
- nanoseconds (including seconds)public static Interval ofYearsMonths(long years, int months)
If both arguments are not equal to zero they should have the same sign.
years
- years, |years|<1018months
- months, |months|<12public static Interval ofDaysHours(long days, int hours)
If both arguments are not equal to zero they should have the same sign.
days
- days, |days|<1018hours
- hours, |hours|<24public static Interval ofDaysHoursMinutes(long days, int hours, int minutes)
Non-zero arguments should have the same sign.
days
- days, |days|<1018hours
- hours, |hours|<24minutes
- minutes, |minutes|<60public static Interval ofDaysHoursMinutesSeconds(long days, int hours, int minutes, int seconds)
Non-zero arguments should have the same sign.
days
- days, |days|<1018hours
- hours, |hours|<24minutes
- minutes, |minutes|<60seconds
- seconds, |seconds|<60public static Interval ofDaysHoursMinutesNanos(long days, int hours, int minutes, long nanos)
Non-zero arguments should have the same sign.
days
- days, |days|<1018hours
- hours, |hours|<24minutes
- minutes, |minutes|<60nanos
- nanoseconds, |nanos|<60,000,000,000public static Interval ofHoursMinutes(long hours, int minutes)
If both arguments are not equal to zero they should have the same sign.
hours
- hours, |hours|<1018minutes
- minutes, |minutes|<60public static Interval ofHoursMinutesSeconds(long hours, int minutes, int seconds)
Non-zero arguments should have the same sign.
hours
- hours, |hours|<1018minutes
- minutes, |minutes|<60seconds
- seconds, |seconds|<60public static Interval ofHoursMinutesNanos(long hours, int minutes, long nanos)
Non-zero arguments should have the same sign.
hours
- hours, |hours|<1018minutes
- minutes, |minutes|<60nanos
- nanoseconds, |seconds|<60,000,000,000public static Interval ofMinutesSeconds(long minutes, int seconds)
If both arguments are not equal to zero they should have the same sign.
minutes
- minutes, |minutes|<1018seconds
- seconds, |seconds|<60public static Interval ofMinutesNanos(long minutes, long nanos)
If both arguments are not equal to zero they should have the same sign.
minutes
- minutes, |minutes|<1018nanos
- nanoseconds, |nanos|<60,000,000,000public IntervalQualifier getQualifier()
public boolean isNegative()
public long getLeading()
SECOND
intervals returns integer part of seconds.public long getRemaining()
SECOND
intervals returns nanoseconds.public long getYears()
public long getMonths()
public long getDays()
public long getHours()
public long getMinutes()
public long getSeconds()
public long getNanosOfSecond()
public long getSecondsAndNanos()
This method returns a long value that cannot fit all possible values of
INTERVAL SECOND. For a very large intervals of this type use
getSeconds()
and getNanosOfSecond()
instead. This
method can be safely used for intervals of other day-time types.
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object