public class LocalDateTimeUtils
extends java.lang.Object
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.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.Class<?> |
DURATION
Class<java.time.Duration> or null. |
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. |
static java.lang.Class<?> |
PERIOD
Class<java.time.Period> or null. |
| Modifier and Type | Method and Description |
|---|---|
static ValueInterval |
durationToValue(java.lang.Object duration)
Converts a Duration to a Value.
|
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 ValueTimestampTimeZone |
offsetDateTimeToValue(java.lang.Object offsetDateTime)
Converts a OffsetDateTime to a Value.
|
static ValueInterval |
periodToValue(java.lang.Object period)
Converts a Period to a Value.
|
static java.lang.Object |
valueToDuration(Value value)
Converts a value to a Duration.
|
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.
|
static java.lang.Object |
valueToPeriod(Value value)
Converts a value to a Period.
|
public static final java.lang.Class<?> LOCAL_DATE
Class<java.time.LocalDate> or null.public static final java.lang.Class<?> LOCAL_TIME
Class<java.time.LocalTime> or null.public static final java.lang.Class<?> LOCAL_DATE_TIME
Class<java.time.LocalDateTime> or null.public static final java.lang.Class<?> INSTANT
Class<java.time.Instant> or null.public static final java.lang.Class<?> OFFSET_DATE_TIME
Class<java.time.OffsetDateTime> or null.public static final java.lang.Class<?> PERIOD
Class<java.time.Period> or null.public static final java.lang.Class<?> DURATION
Class<java.time.Duration> or null.public static boolean isJava8DateApiPresent()
This is the case on Java 8 and later and not the case on Java 7. Versions older than Java 7 are not supported.
public static java.lang.Object valueToLocalDate(Value value)
This method should only called from Java 8 or later.
value - the value to convertpublic static java.lang.Object valueToLocalTime(Value value)
This method should only called from Java 8 or later.
value - the value to convertpublic static java.lang.Object valueToLocalDateTime(Value value)
This method should only called from Java 8 or later.
value - the value to convertpublic static java.lang.Object valueToInstant(Value value)
This method should only called from Java 8 or later.
value - the value to convertpublic static java.lang.Object valueToOffsetDateTime(Value value)
This method should only called from Java 8 or later.
value - the value to convertpublic static java.lang.Object valueToPeriod(Value value)
This method should only called from Java 8 or later.
value - the value to convertpublic static java.lang.Object valueToDuration(Value value)
This method should only called from Java 8 or later.
value - the value to convertpublic static Value localDateToDateValue(java.lang.Object localDate)
localDate - the LocalDate to convert, not nullpublic static Value localTimeToTimeValue(java.lang.Object localTime)
localTime - the LocalTime to convert, not nullpublic static Value localDateTimeToValue(java.lang.Object localDateTime)
localDateTime - the LocalDateTime to convert, not nullpublic static Value instantToValue(java.lang.Object instant)
instant - the Instant to convert, not nullpublic static ValueTimestampTimeZone offsetDateTimeToValue(java.lang.Object offsetDateTime)
offsetDateTime - the OffsetDateTime to convert, not nullpublic static ValueInterval periodToValue(java.lang.Object period)
period - the Period to convert, not nullpublic static ValueInterval durationToValue(java.lang.Object duration)
duration - the Duration to convert, not null