YearToMonth / DayToSecond interval.
Some databases (e.g. PostgreSQL) allow for mixing YEAR TO MONTH
and DAY TO SECOND intervals, despite the many questions such a
combination raises. The YearToSecond type intends to model such
vendor specific intervals.
The numeric value of this interval corresponds to its "context free" number
of milliseconds. While the DayToSecond interval component can provide
such a value easily (being independent of time zones, daylight saving times,
leap years, or leap seconds), the YearToMonth component cannot. The
implemented rules are those of PostgreSQL:
Examples:
P11M has 330 daysP1Y-1M has 330 daysP1Y has 365.25 daysP1Y1M has 396.25 days| Modifier and Type | Field and Description |
|---|---|
| private final DayToSecond | |
| private static final Pattern | |
| private final YearToMonth |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final YearToSecond | abs()
Implements org. |
| public final int | compareTo(YearToSecond
the object to be compared. that)Implements java. |
| public final double | doubleValue()
Implements abstract java. Implements org. double.
|
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. |
| public final float | floatValue()
Implements abstract java. Implements org. float.
|
| public final int | |
| public final DayToSecond | |
| public final int | |
| public final int | |
| public final int | |
| public final int | |
| public final int | |
| public final int | |
| public final int | |
| public final int | |
| public final int | |
| public final YearToMonth | |
| public int | |
| public final int | intValue()
Implements abstract java. Implements org. int.
|
| public final long | longValue()
Implements abstract java. Implements org. long.
|
| public final YearToSecond | |
| pack-priv static DayToSecond | |
| pack-priv static YearToMonth | |
| public final Duration | toDuration()
Implements org. |
| public final String | |
| public static YearToSecond | |
| public static YearToSecond | valueOf(Duration duration)
Transform a |
| public static YearToSecond | |
| public static YearToSecond |
| dayToSecond | back to summary |
|---|---|
| private final DayToSecond dayToSecond | |
| PATTERN | back to summary |
|---|---|
| private static final Pattern PATTERN | |
| yearToMonth | back to summary |
|---|---|
| private final YearToMonth yearToMonth | |
| YearToSecond | back to summary |
|---|---|
| public YearToSecond(YearToMonth yearToMonth, DayToSecond dayToSecond) | |
| abs | back to summary |
|---|---|
| public final YearToSecond abs() Implements org. Doc from org. Get the absolute value of the interval (set its sign to positive)
| |
| compareTo | back to summary |
|---|---|
| public final int compareTo(YearToSecond that) Implements java. Doc from java. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The implementor must ensure The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| doubleValue | back to summary |
|---|---|
| public final double doubleValue() Implements abstract java. Implements org. Doc from java. Returns the value of the specified number as a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| floatValue | back to summary |
|---|---|
| public final float floatValue() Implements abstract java. Implements org. Doc from java. Returns the value of the specified number as a
| |
| getDays | back to summary |
|---|---|
| public final int getDays() Get the day-part of this interval | |
| getDayToSecond | back to summary |
|---|---|
| public final DayToSecond getDayToSecond() | |
| getHours | back to summary |
|---|---|
| public final int getHours() Get the hour-part of this interval | |
| getMicro | back to summary |
|---|---|
| public final int getMicro() Get the (truncated) micro-part of this interval | |
| getMilli | back to summary |
|---|---|
| public final int getMilli() Get the (truncated) milli-part of this interval | |
| getMinutes | back to summary |
|---|---|
| public final int getMinutes() Get the minute-part of this interval | |
| getMonths | back to summary |
|---|---|
| public final int getMonths() | |
| getNano | back to summary |
|---|---|
| public final int getNano() Get the nano-part of this interval | |
| getSeconds | back to summary |
|---|---|
| public final int getSeconds() Get the second-part of this interval | |
| getSign | back to summary |
|---|---|
| public final int getSign() Implements org. Doc from org. The sign of the interval
| |
| getYears | back to summary |
|---|---|
| public final int getYears() | |
| getYearToMonth | back to summary |
|---|---|
| public final YearToMonth getYearToMonth() | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| intValue | back to summary |
|---|---|
| public final int intValue() Implements abstract java. Implements org. Doc from java. Returns the value of the specified number as an
| |
| longValue | back to summary |
|---|---|
| public final long longValue() Implements abstract java. Implements org. Doc from java. Returns the value of the specified number as a
| |
| neg | back to summary |
|---|---|
| public final YearToSecond neg() Implements org. Doc from org. Negate the interval (change its sign)
| |
| parseDS | back to summary |
|---|---|
| pack-priv static DayToSecond parseDS(Matcher matcher, int groupOffset) | |
| parseYM | back to summary |
|---|---|
| pack-priv static YearToMonth parseYM(Matcher matcher, int groupOffset) | |
| toDuration | back to summary |
|---|---|
| public final Duration toDuration() Implements org. Doc from org. Get a duration representation of this interval.
There is an obvious
This corresponds to PostgreSQL's
| |
| toString | back to summary |
|---|---|
| public final String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| valueOf | back to summary |
|---|---|
| public static YearToSecond valueOf(double milli) Load a
| |
| valueOf | back to summary |
|---|---|
| public static YearToSecond valueOf(Duration duration) Transform a | |
| valueOf | back to summary |
|---|---|
| public static YearToSecond valueOf(Period period) Transform a | |
| valueOf | back to summary |
|---|---|
| public static YearToSecond valueOf(String string) Parse a string representation of a
| |