Package org.apache.calcite.avatica.util

# Enum TimeUnit

java.lang.Object
java.lang.Enum<TimeUnit>
org.apache.calcite.avatica.util.TimeUnit

All Implemented Interfaces:
  `Serializable`, `Comparable<TimeUnit>`, `java.lang.constant.Constable`

public enum TimeUnit extends Enum<TimeUnit>
Enumeration of time units used to construct an interval.

Only `YEAR`, `MONTH`, `DAY`, `HOUR`, `MINUTE`, `SECOND` can be the unit of a SQL interval.

The others (`QUARTER`, `WEEK`, `MILLISECOND`, `DOW`, `DOY`, `EPOCH`, `DECADE`, `CENTURY`, `MILLENNIUM`, `MICROSECOND`, `NANOSECOND`, `ISODOW` and `ISOYEAR`) are convenient to use internally, when converting to and from UNIX timestamps. And also may be arguments to the `EXTRACT`, `TIMESTAMPADD` and `TIMESTAMPDIFF` functions.

## Nested Class Summary

## Nested classes/interfaces inherited from class java.lang.Enum

`Enum.EnumDesc<E extends Enum<E>>`

## Enum Constant Summary

Enum Constants
Enum Constant
Description
`CENTURY`
`DAY`
`DECADE`
`DOW`
`DOY`
`EPOCH`
`HOUR`
`ISODOW`
`ISOYEAR`
`MICROSECOND`
`MILLENNIUM`
`MILLISECOND`
`MINUTE`
`MONTH`
`NANOSECOND`
`QUARTER`
`SECOND`
`WEEK`
`YEAR`

## Field Summary

Fields
Modifier and Type
Field
Description
`final BigDecimal`
`multiplier`
`final char`
`separator`
`final boolean`
`yearMonth`

## Method Summary

Modifier and Type
Method
Description
`static TimeUnit`
`getValue(int ordinal)`
Returns the TimeUnit associated with an ordinal.
`boolean`
`isValidValue(BigDecimal field)`
Returns whether a given value is valid for a field of this time unit.
`static TimeUnit`
`valueOf(String name)`
Returns the enum constant of this type with the specified name.
`static TimeUnit[]`
`values()`
Returns an array containing the constants of this enum type, in the order they are declared.

### Methods inherited from class java.lang.Enum

`clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

## Enum Constant Details

### YEAR

public static final TimeUnit YEAR

### MONTH

public static final TimeUnit MONTH

### DAY

public static final TimeUnit DAY

### HOUR

public static final TimeUnit HOUR

### MINUTE

public static final TimeUnit MINUTE

### SECOND

public static final TimeUnit SECOND

### QUARTER

public static final TimeUnit QUARTER

### ISOYEAR

public static final TimeUnit ISOYEAR

### WEEK

public static final TimeUnit WEEK

### MILLISECOND

public static final TimeUnit MILLISECOND

### MICROSECOND

public static final TimeUnit MICROSECOND

### NANOSECOND

public static final TimeUnit NANOSECOND

### DOW

public static final TimeUnit DOW

### ISODOW

public static final TimeUnit ISODOW

### DOY

public static final TimeUnit DOY

### EPOCH

public static final TimeUnit EPOCH

### DECADE

public static final TimeUnit DECADE

### CENTURY

public static final TimeUnit CENTURY

### MILLENNIUM

public static final TimeUnit MILLENNIUM

## Field Details

### yearMonth

public final boolean yearMonth

### separator

public final char separator

### multiplier

public final BigDecimal multiplier

## Method Details

### values

public static TimeUnit[] values()
Returns an array containing the constants of this enum type, in the order they are declared.

Returns:
  an array containing the constants of this enum type, in the order they are declared

### valueOf

public static TimeUnit valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
  `NullPointerException` - if the argument is null

### getValue

public static TimeUnit getValue(int ordinal)
Returns the TimeUnit associated with an ordinal. The value returned is null if the ordinal is not a member of the TimeUnit enumeration.

### isValidValue

public boolean isValidValue(BigDecimal field)
Returns whether a given value is valid for a field of this time unit.

Parameters:
  `field` - Field value
Returns:
  Whether value