Enum Class IntervalUnit
- All Implemented Interfaces:
Serializable,Comparable<IntervalUnit>,Constable
The unit of an
IntervalExpression. One constant per UNIT, with the many spellings live
accepts for each resolved by fromSpelling(java.lang.String): year, y, yy, yyyy,
yr and years are one unit, not six.
EVERY SPELLING HERE WAS READ OFF A LIVE ACCOUNT, and the list has holes no rule predicts. Adding one because it looks like its neighbours is how this list goes wrong: a first draft guessed fifteen from the pattern and FOUR were refused live —
wk accepted wks REFUSED sec accepted ss REFUSED woy accepted wofy REFUSED msec accepted msecs REFUSED usec accepted usecs REFUSED nanosecs accepted nsecs REFUSED
So do not "tidy" or extend this list. Measure the spelling, then add it.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescription -
Method Summary
Modifier and TypeMethodDescriptionstatic IntervalUnitfromSpelling(String text) The unit a spelling names, or null when live does not recognise it either.booleanWhether this unit measures a WHOLE DAY or more, which decides whether adding it to a DATE leaves a DATE or promotes to TIMESTAMP_NTZ.static IntervalUnitReturns the enum constant of this class with the specified name.static IntervalUnit[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
YEAR
-
QUARTER
-
MONTH
-
WEEK
-
DAY
-
HOUR
-
MINUTE
-
SECOND
-
MILLISECOND
-
MICROSECOND
-
NANOSECOND
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
fromSpelling
The unit a spelling names, or null when live does not recognise it either.- Parameters:
text- the unit word as written, in any case- Returns:
- the unit, or null when the spelling is not one live accepts
-
isWholeDay
public boolean isWholeDay()Whether this unit measures a WHOLE DAY or more, which decides whether adding it to a DATE leaves a DATE or promotes to TIMESTAMP_NTZ. DAY is the one unit whose answer also depends on which INTERVAL spelling was used — seeIntervalExpression.isUnitInString().- Returns:
- true for year, quarter, month, week and day
-