Package com.exasol.datatype.value
Class IntervalYearToMonth
- java.lang.Object
-
- com.exasol.datatype.value.AbstractInterval
-
- com.exasol.datatype.value.IntervalYearToMonth
-
public final class IntervalYearToMonth extends AbstractInterval
This class implements the Exasol-proprietary data type valueINTERVAL YEAR(x) TO MONTH(y)
. It supports conversions to and from strings and from a number of months.In Exasol this data type represents a time difference consisting of the following components:
- years
- months
Since months are the highest resolution, each interval can also be expressed as a total number of months. This is also the recommended way to represent the interval values in other systems which do not natively support this data type.
-
-
Field Summary
-
Fields inherited from class com.exasol.datatype.value.AbstractInterval
positive, value
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static IntervalYearToMonth
ofMonths(long value)
Create anIntervalDayToSecond
from a number of monthsstatic IntervalYearToMonth
parse(String text)
Parse anIntervalDayToSecond
from a stringlong
toMonths()
Get the interval as the total number of months between two points in timeString
toString()
-
Methods inherited from class com.exasol.datatype.value.AbstractInterval
getSign, getSignedValue, parseMatchingGroupToLong
-
-
-
-
Method Detail
-
toMonths
public long toMonths()
Get the interval as the total number of months between two points in time- Returns:
- total number of months
-
ofMonths
public static IntervalYearToMonth ofMonths(long value)
Create anIntervalDayToSecond
from a number of months- Parameters:
value
- total length of the interval in months- Returns:
- interval with months resolution
-
parse
public static IntervalYearToMonth parse(String text)
Parse anIntervalDayToSecond
from a stringThe accepted format is:
YYYYYYYYY:MM
Where
- Y
- years, 1-9 digits, mandatory
- M
- months, 1-2 digits, mandatory
- Parameters:
text
- string representing an interval- Returns:
- interval with months resolution
-
-