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.
Dialect#extractPattern(TemporalUnit)
| Modifier and Type | Field and Description |
|---|---|
| public static final TemporalUnit | DATE
The date part of a timestamp, datetime, or offset datetime,
as a |
| public static final TemporalUnit | 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 to |
| public static final TemporalUnit | DAY_OF_MONTH
The calendar day of the month, a synonym for |
| public static final TemporalUnit | DAY_OF_WEEK
The day of the week, from 1 (Sunday) to 7 (Saturday). |
| public static final TemporalUnit | DAY_OF_YEAR
The day of the year, counting from 1. |
| public static final TemporalUnit | EPOCH
An internal value representing the Unix epoch, the elapsed seconds since January 1, 1970. |
| public static final TemporalUnit | 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
to |
| public static final TemporalUnit | 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 to |
| public static final TemporalUnit | MONTH
Calendar month. |
| public static final TemporalUnit | NANOSECOND
Nanosecond, the basic most granular unit of duration. |
| public static final TemporalUnit | NATIVE
An internal value representing the "native" resolution for date/time arithmetic of the underlying platform. |
| public static final TemporalUnit | OFFSET
The timezone offset of an offset datetime, as a
|
| public static final TemporalUnit | QUARTER
Quarter, defined to mean three months. |
| public static final TemporalUnit | 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 to
|
| public static final TemporalUnit | TIME
The time part of a timestamp, datetime, or offset datetime,
as a |
| public static final TemporalUnit | TIMEZONE_HOUR
The hour field of the |
| public static final TemporalUnit | TIMEZONE_MINUTE
The minute field of the |
| public static final TemporalUnit | 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 to |
| public static final TemporalUnit | 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. |
| public static final TemporalUnit | 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. |
| public static final TemporalUnit | YEAR
Calendar year. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public String | |
| private static String | Returns: a string to inject into the SQL expressionthe conversion factor factor)Obtain a fragment of SQL that can be used to perform a unit conversion. |
| public boolean | |
| public boolean | |
| private long | normalizationFactor(Dialect dialect)
The conversion factor required to convert this
unit to its |
| public TemporalUnit | normalized()
The unit that this unit "normalizes to",
either |
| public String | toString()
Overrides java. |
| public static TemporalUnit | |
| public static TemporalUnit[] |
| DATE | back to summary |
|---|---|
| public static final TemporalUnit DATE The date part of a timestamp, datetime, or offset datetime,
as a | |
| DAY | back to summary |
|---|---|
| public static final TemporalUnit 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 to | |
| DAY_OF_MONTH | back to summary |
|---|---|
| public static final TemporalUnit DAY_OF_MONTH The calendar day of the month, a synonym for | |
| DAY_OF_WEEK | back to summary |
|---|---|
| public static final TemporalUnit DAY_OF_WEEK The day of the week, from 1 (Sunday) to 7 (Saturday). Not supported by every database platform. | |
| DAY_OF_YEAR | back to summary |
|---|---|
| public static final TemporalUnit DAY_OF_YEAR The day of the year, counting from 1. Not supported by every database platform. | |
| EPOCH | back to summary |
|---|---|
| public static final TemporalUnit EPOCH An internal value representing the Unix epoch, the elapsed seconds since January 1, 1970. | |
| HOUR | back to summary |
|---|---|
| public static final TemporalUnit 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
to | |
| MINUTE | back to summary |
|---|---|
| public static final TemporalUnit 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 to | |
| MONTH | back to summary |
|---|---|
| public static final TemporalUnit MONTH Calendar month. | |
| NANOSECOND | back to summary |
|---|---|
| public static final TemporalUnit NANOSECOND Nanosecond, the basic most granular unit of duration.
Few databases support billions-of-seconds, but Java's
Note that the actual minimum granularity of a datetime varies by database platform (usually milliseconds or microseconds) so support for nanoseconds is emulated.
| |
| NATIVE | back to summary |
|---|---|
| public static final TemporalUnit 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 between | |
| OFFSET | back to summary |
|---|---|
| public static final TemporalUnit OFFSET The timezone offset of an offset datetime, as a
| |
| QUARTER | back to summary |
|---|---|
| public static final TemporalUnit QUARTER Quarter, defined to mean three months. | |
| SECOND | back to summary |
|---|---|
| public static final TemporalUnit 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 to
| |
| TIME | back to summary |
|---|---|
| public static final TemporalUnit TIME The time part of a timestamp, datetime, or offset datetime,
as a | |
| TIMEZONE_HOUR | back to summary |
|---|---|
| public static final TemporalUnit TIMEZONE_HOUR The hour field of the | |
| TIMEZONE_MINUTE | back to summary |
|---|---|
| public static final TemporalUnit TIMEZONE_MINUTE The minute field of the | |
| WEEK | back to summary |
|---|---|
| public static final TemporalUnit 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 to | |
| WEEK_OF_MONTH | back to summary |
|---|---|
| public static final TemporalUnit 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
| |
| WEEK_OF_YEAR | back to summary |
|---|---|
| public static final TemporalUnit 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 to
Supported on all platforms which natively support
| |
| YEAR | back to summary |
|---|---|
| public static final TemporalUnit YEAR Calendar year. | |
| TemporalUnit | back to summary |
|---|---|
| private TemporalUnit() | |
| conversionFactor | back to summary |
|---|---|
| public String conversionFactor(TemporalUnit unit, Dialect dialect) | |
| conversionFactorFull | back to summary |
|---|---|
| public String conversionFactorFull(TemporalUnit unit, Dialect dialect) | |
| factorAsString | back to summary |
|---|---|
| private static String factorAsString(long factor) Obtain a fragment of SQL that can be used to perform a unit conversion. If the normalization factor is very large, represent it using exponential form so as to minimize the noise the generated SQL.
| |
| isDateUnit | back to summary |
|---|---|
| public boolean isDateUnit() Is this unit extractable from a date? | |
| isTimeUnit | back to summary |
|---|---|
| public boolean isTimeUnit() Is this unit extractable from a time? | |
| normalizationFactor | back to summary |
|---|---|
| private long normalizationFactor(Dialect dialect) The conversion factor required to convert this
unit to its | |
| normalized | back to summary |
|---|---|
| public TemporalUnit normalized() The unit that this unit "normalizes to",
either | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists. | |
| valueOf | back to summary |
|---|---|
| public static TemporalUnit valueOf(String name) | |
| values | back to summary |
|---|---|
| public static TemporalUnit[] values() | |