org.h2.util

## Class LocalDateTimeUtils

- java.lang.Object
- - org.h2.util.LocalDateTimeUtils

    public class LocalDateTimeUtils
    extends java.lang.Object

This utility class contains time conversion functions for Java 8 Date and Time API classes.

This class is implemented using reflection so that it compiles on Java 7 as well.

Custom conversion methods between H2 internal values and JSR-310 classes are used in most cases without intermediate conversions to java.sql classes. Direct conversion is simpler, faster, and it does not inherit limitations and issues from java.sql classes and conversion methods provided by JDK.

The only one exclusion is a conversion between `Timestamp` and Instant.

Once the driver requires Java 8 and Android API 26 all the reflection can be removed.

### Field Summary

Fields
`static java.lang.Class<?>` `INSTANT` `Class<java.time.Instant>` or `null`.
`static java.lang.Class<?>` `LOCAL_DATE` `Class<java.time.LocalDate>` or `null`.
`static java.lang.Class<?>` `LOCAL_DATE_TIME` `Class<java.time.LocalDateTime>` or `null`.
`static java.lang.Class<?>` `LOCAL_TIME` `Class<java.time.LocalTime>` or `null`.
`static java.lang.Class<?>` `OFFSET_DATE_TIME` `Class<java.time.OffsetDateTime>` or `null`.

### Method Summary

Methods
`static Value` `instantToValue(java.lang.Object instant)` Converts a Instant to a Value.
`static boolean` `isJava8DateApiPresent()` Checks if the Java 8 Date and Time API is present.
`static Value` `localDateTimeToValue(java.lang.Object localDateTime)` Converts a LocalDateTime to a Value.
`static Value` `localDateToDateValue(java.lang.Object localDate)` Converts a LocalDate to a Value.
`static Value` `localTimeToTimeValue(java.lang.Object localTime)` Converts a LocalTime to a Value.
`static Value` `offsetDateTimeToValue(java.lang.Object offsetDateTime)` Converts a OffsetDateTime to a Value.
`static java.lang.Object` `parseLocalDate(java.lang.CharSequence text)` Parses an ISO date string into a java.time.LocalDate.
`static java.lang.Object` `parseLocalDateTime(java.lang.CharSequence text)` Parses an ISO date string into a java.time.LocalDateTime.
`static java.lang.Object` `parseLocalTime(java.lang.CharSequence text)` Parses an ISO time string into a java.time.LocalTime.
`static java.lang.Object` `parseOffsetDateTime(java.lang.CharSequence text)` Parses an ISO date string into a java.time.OffsetDateTime.
`static java.lang.Object` `valueToInstant(Value value)` Converts a value to a Instant.
`static java.lang.Object` `valueToLocalDate(Value value)` Converts a value to a LocalDate.
`static java.lang.Object` `valueToLocalDateTime(Value value)` Converts a value to a LocalDateTime.
`static java.lang.Object` `valueToLocalTime(Value value)` Converts a value to a LocalTime.
`static java.lang.Object` `valueToOffsetDateTime(Value value)` Converts a value to a OffsetDateTime.

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### LOCAL_DATE

    public static final java.lang.Class<?> LOCAL_DATE

`Class<java.time.LocalDate>` or `null`.

#### LOCAL_TIME

    public static final java.lang.Class<?> LOCAL_TIME

`Class<java.time.LocalTime>` or `null`.

#### LOCAL_DATE_TIME

    public static final java.lang.Class<?> LOCAL_DATE_TIME

`Class<java.time.LocalDateTime>` or `null`.

#### INSTANT

    public static final java.lang.Class<?> INSTANT

`Class<java.time.Instant>` or `null`.

#### OFFSET_DATE_TIME

    public static final java.lang.Class<?> OFFSET_DATE_TIME

`Class<java.time.OffsetDateTime>` or `null`.

### Method Detail

#### isJava8DateApiPresent

    public static boolean isJava8DateApiPresent()

Checks if the Java 8 Date and Time API is present.

This is the case on Java 8 and later and not the case on Java 7. Versions older than Java 7 are not supported.

Returns:
  if the Java 8 Date and Time API is present

#### parseLocalDate

    public static java.lang.Object parseLocalDate(java.lang.CharSequence text)

Parses an ISO date string into a java.time.LocalDate.

Parameters:
  `text` - the ISO date string
Returns:
  the java.time.LocalDate instance

#### parseLocalTime

    public static java.lang.Object parseLocalTime(java.lang.CharSequence text)

Parses an ISO time string into a java.time.LocalTime.

Parameters:
  `text` - the ISO time string
Returns:
  the java.time.LocalTime instance

#### parseLocalDateTime

    public static java.lang.Object parseLocalDateTime(java.lang.CharSequence text)

Parses an ISO date string into a java.time.LocalDateTime.

Parameters:
  `text` - the ISO date string
Returns:
  the java.time.LocalDateTime instance

#### parseOffsetDateTime

    public static java.lang.Object parseOffsetDateTime(java.lang.CharSequence text)

Parses an ISO date string into a java.time.OffsetDateTime.

Parameters:
  `text` - the ISO date string
Returns:
  the java.time.OffsetDateTime instance

#### valueToLocalDate

    public static java.lang.Object valueToLocalDate(Value value)

Converts a value to a LocalDate.

This method should only called from Java 8 or later.

Parameters:
  `value` - the value to convert
Returns:
  the LocalDate

#### valueToLocalTime

    public static java.lang.Object valueToLocalTime(Value value)

Converts a value to a LocalTime.

This method should only called from Java 8 or later.

Parameters:
  `value` - the value to convert
Returns:
  the LocalTime

#### valueToLocalDateTime

    public static java.lang.Object valueToLocalDateTime(Value value)

Converts a value to a LocalDateTime.

This method should only called from Java 8 or later.

Parameters:
  `value` - the value to convert
Returns:
  the LocalDateTime

#### valueToInstant

    public static java.lang.Object valueToInstant(Value value)

Converts a value to a Instant.

This method should only called from Java 8 or later.

Parameters:
  `value` - the value to convert
Returns:
  the Instant

#### valueToOffsetDateTime

    public static java.lang.Object valueToOffsetDateTime(Value value)

Converts a value to a OffsetDateTime.

This method should only called from Java 8 or later.

Parameters:
  `value` - the value to convert
Returns:
  the OffsetDateTime

#### localDateToDateValue

    public static Value localDateToDateValue(java.lang.Object localDate)

Converts a LocalDate to a Value.

Parameters:
  `localDate` - the LocalDate to convert, not `null`
Returns:
  the value

#### localTimeToTimeValue

    public static Value localTimeToTimeValue(java.lang.Object localTime)

Converts a LocalTime to a Value.

Parameters:
  `localTime` - the LocalTime to convert, not `null`
Returns:
  the value

#### localDateTimeToValue

    public static Value localDateTimeToValue(java.lang.Object localDateTime)

Converts a LocalDateTime to a Value.

Parameters:
  `localDateTime` - the LocalDateTime to convert, not `null`
Returns:
  the value

#### instantToValue

    public static Value instantToValue(java.lang.Object instant)

Converts a Instant to a Value.

Parameters:
  `instant` - the Instant to convert, not `null`
Returns:
  the value

#### offsetDateTimeToValue

    public static Value offsetDateTimeToValue(java.lang.Object offsetDateTime)

Converts a OffsetDateTime to a Value.

Parameters:
  `offsetDateTime` - the OffsetDateTime to convert, not `null`
Returns:
  the value