Enum Class TemporalUnit
- All Implemented Interfaces:
Serializable
,Comparable<TemporalUnit>
,Constable
extract()
or as the unit of a duration
expression. A temporal field type may also occur as
an argument to timestampadd()
or
timestampdiff()
, in which case it is
interpreted as a unit of duration.
Note that not every TemporalUnit
is legal
duration unit. The units of a duration are:
YEAR
, MONTH
, DAY
,
HOUR
, MINUTE
, SECOND
,
WEEK
, QUARTER
, and
NANOSECOND
.
Further note that accepted unit types in
extract()
vary according to the type of the
second argument (date, time, or timestamp), and
according to capabilities of the database platform.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe date part of a timestamp, datetime, or offset datetime, as aLocalDate
.Day, defined to mean 24 hours when it occurs as a unit of duration, or to mean the calendar day of the month when passed toextract()
.The calendar day of the month, a synonym forDAY
.The day of the week, from 1 (Sunday) to 7 (Saturday).The day of the year, counting from 1.An internal value representing the Unix epoch, the elapsed seconds since January 1, 1970.Hour, defined to mean 60 minutes when it occurs as a unit of duration, or to mean the hour field in the range 0-23 (regular 24-hour time) when passed toextract()
.Minute, defined to mean 60 seconds when it occurs as a unit of duration, or to mean the minute field in the range 0-59 when passed toextract()
.Calendar month.Nanosecond, the basic most granular unit of duration.An internal value representing the "native" resolution for date/time arithmetic of the underlying platform.The timezone offset of an offset datetime, as aZoneOffset
.Quarter, defined to mean three months.Second, defined to mean 1000 nanoseconds when it occurs as a unit of duration, or to mean the second field in the range 0-59 when passed toextract()
.The time part of a timestamp, datetime, or offset datetime, as aLocalTime
.The hour field of theOFFSET
in an offset datetime.The minute field of theOFFSET
in an offset datetime.Week, defined to mean 7 days when it occurs as a unit of duration, or to mean the ISO ISO-8601 week number when passed toextract()
.The week of the month, where the first day of the month is in week 1, and a new week starts each Sunday.The week of the year, where the first day of the year is in week 1, and a new week starts each Sunday.Calendar year. -
Method Summary
Modifier and TypeMethodDescriptionconversionFactor
(TemporalUnit unit, Dialect dialect) conversionFactorFull
(TemporalUnit unit, Dialect dialect) boolean
Is this unit extractable from a date?boolean
Is this unit extractable from a time?The unit that this unit "normalizes to", eitherNANOSECOND
orMONTH
, which represent the two basic types of duration: "physical" durations, and "calendar" durations.toString()
static TemporalUnit
Returns the enum constant of this class with the specified name.static TemporalUnit[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
YEAR
Calendar year. -
QUARTER
Quarter, defined to mean three months. -
MONTH
Calendar month. -
WEEK
Week, defined to mean 7 days when it occurs as a unit of duration, or to mean the ISO ISO-8601 week number when passed toextract()
. This is different toWEEK_OF_YEAR
. -
DAY
Day, defined to mean 24 hours when it occurs as a unit of duration, or to mean the calendar day of the month when passed toextract()
. -
HOUR
Hour, defined to mean 60 minutes when it occurs as a unit of duration, or to mean the hour field in the range 0-23 (regular 24-hour time) when passed toextract()
. -
MINUTE
Minute, defined to mean 60 seconds when it occurs as a unit of duration, or to mean the minute field in the range 0-59 when passed toextract()
. -
SECOND
Second, defined to mean 1000 nanoseconds when it occurs as a unit of duration, or to mean the second field in the range 0-59 when passed toextract()
. The second field includes fractional seconds (it is a floating point value). -
NANOSECOND
Nanosecond, the basic most granular unit of duration. Few databases support billions-of-seconds, but Java'sDuration
type does. When it occurs as an argument toextract()
, the nanosecond field is interpreted to include full seconds.Note that the actual minimum granularity of a datetime varies by database platform (usually milliseconds or microseconds) so support for nanoseconds is emulated.
- See Also:
-
DAY_OF_WEEK
The day of the week, from 1 (Sunday) to 7 (Saturday).Not supported by every database platform.
-
DAY_OF_YEAR
The day of the year, counting from 1.Not supported by every database platform.
-
DAY_OF_MONTH
The calendar day of the month, a synonym forDAY
. -
WEEK_OF_MONTH
The week of the month, where the first day of the month is in week 1, and a new week starts each Sunday.Supported on all platforms which natively support
DAY_OF_WEEK
. -
WEEK_OF_YEAR
The week of the year, where the first day of the year is in week 1, and a new week starts each Sunday. This is different toWEEK
.Supported on all platforms which natively support
DAY_OF_WEEK
andDAY_OF_YEAR
. -
OFFSET
The timezone offset of an offset datetime, as aZoneOffset
. -
TIMEZONE_HOUR
The hour field of theOFFSET
in an offset datetime. -
TIMEZONE_MINUTE
The minute field of theOFFSET
in an offset datetime. -
DATE
The date part of a timestamp, datetime, or offset datetime, as aLocalDate
. -
TIME
The time part of a timestamp, datetime, or offset datetime, as aLocalTime
. -
EPOCH
An internal value representing the Unix epoch, the elapsed seconds since January 1, 1970. -
NATIVE
An internal value representing the "native" resolution for date/time arithmetic of the underlying platform. Usually the smallest unit of fractional seconds, either milliseconds or microseconds. We define this value in order to avoid repeatedly converting betweenNANOSECOND
s and a unit that the database understands. On some platforms this is also used to avoid numeric overflow.
-
-
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
-
conversionFactor
-
conversionFactorFull
-
isDateUnit
public boolean isDateUnit()Is this unit extractable from a date? -
isTimeUnit
public boolean isTimeUnit()Is this unit extractable from a time? -
normalized
The unit that this unit "normalizes to", eitherNANOSECOND
orMONTH
, which represent the two basic types of duration: "physical" durations, and "calendar" durations. -
toString
- Overrides:
toString
in classEnum<TemporalUnit>
-