Top Description Fields Constructors Methods
org.h2.util

public final Class LegacyDateTimeUtils

extends Object
Class Inheritance
Static Imports
org.h2.util.DateTimeUtils.MILLIS_PER_DAY, .DateTimeUtils.NANOS_PER_SECOND

Date and time utilities for Date, Time, and Timestamp classes.

Field Summary

Modifier and TypeField and Description
public static final Date
PROLEPTIC_GREGORIAN_CHANGE

Gregorian change date for a java.util.GregorianCalendar that represents a proleptic Gregorian calendar.

public static final TimeZone
UTC

UTC time zone.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static long

Returns:

the date value
dateValueFromLocalMillis
(long
the milliseconds
ms
)

Convert a local datetime in millis to an encoded date.

public static ValueDate

Returns:

the value
fromDate
(CastDataProvider
the cast information provider
provider
,
TimeZone
time zone, or null for default
timeZone
,
Date
the date
date
)

Get or create a date value for the given date.

public static ValueTime

Returns:

the value
fromTime
(CastDataProvider
the cast information provider
provider
,
TimeZone
time zone, or null for default
timeZone
,
Time
the time
time
)

Get or create a time value for the given time.

public static ValueTimestamp

Returns:

the value
fromTimestamp
(CastDataProvider
the cast information provider
provider
,
TimeZone
time zone, or null for default
timeZone
,
Timestamp
the timestamp
timestamp
)

Get or create a timestamp value for the given timestamp.

public static ValueTimestamp

Returns:

the value
fromTimestamp
(CastDataProvider
the cast information provider
provider
,
long
the milliseconds
ms
,
int
the nanoseconds
nanos
)

Get or create a timestamp value for the given date/time in millis.

public static long

Returns:

the number of milliseconds (UTC)
getMillis
(CastDataProvider
the cast information provider
provider
,
TimeZone
the timezone of the parameters, or null for the default timezone
tz
,
long
date value
dateValue
,
long
nanoseconds since midnight
timeNanos
)

Calculate the milliseconds since 1970-01-01 (UTC) for the given date and time (in the specified timezone).

public static int

Returns:

local time zone offset
getTimeZoneOffsetMillis
(CastDataProvider
the cast information provider
provider
,
long
milliseconds since Epoch in UTC
ms
)

Returns local time zone offset for a specified timestamp.

public static TypeInfo

Returns:

the value type, or null if not supported
legacyClassToType
(Class<?>
the Java class
clazz
)

Get the type information for the given legacy Java class.

public static Value

Returns:

the value, or null if not supported
legacyObjectToValue
(CastDataProvider
the session
session
,
Object
the value
x
)

Convert a legacy Java object to a value.

public static long

Returns:

the nanoseconds
nanosFromLocalMillis
(long
the milliseconds
ms
)

Convert a time in milliseconds in local time to the nanoseconds since midnight.

private static ValueTimestamp
timestampFromLocalMillis(long ms, int nanos)

public static Date

Returns:

the date
toDate
(CastDataProvider
the cast information provider
provider
,
TimeZone
the target time zone
timeZone
,
Value
the value to convert
value
)

Get the date value converted to the specified time zone.

public static Time

Returns:

the time
toTime
(CastDataProvider
the cast information provider
provider
,
TimeZone
the target time zone
timeZone
,
Value
the value to convert
value
)

Get the time value converted to the specified time zone.

public static Timestamp

Returns:

the timestamp
toTimestamp
(CastDataProvider
the cast information provider
provider
,
TimeZone
the target time zone
timeZone
,
Value
the value to convert
value
)

Get the timestamp value converted to the specified time zone.

public static <
the type
T
>
T

Returns:

an instance of the specified class, or null if not supported
valueToLegacyType
(Class<T>
the class
type
,
Value
the value
value
,
CastDataProvider
the cast information provider
provider
)

Converts the specified value to an object of the specified legacy type.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

PROLEPTIC_GREGORIAN_CHANGEback to summary
public static final Date PROLEPTIC_GREGORIAN_CHANGE

Gregorian change date for a java.util.GregorianCalendar that represents a proleptic Gregorian calendar.

UTCback to summary
public static final TimeZone UTC

UTC time zone.

Constructor Detail

LegacyDateTimeUtilsback to summary
private LegacyDateTimeUtils()

Method Detail

dateValueFromLocalMillisback to summary
public static long dateValueFromLocalMillis(long ms)

Convert a local datetime in millis to an encoded date.

Parameters
ms:long

the milliseconds

Returns:long

the date value

fromDateback to summary
public static ValueDate fromDate(CastDataProvider provider, TimeZone timeZone, Date date)

Get or create a date value for the given date.

Parameters
provider:CastDataProvider

the cast information provider

timeZone:TimeZone

time zone, or null for default

date:Date

the date

Returns:ValueDate

the value

fromTimeback to summary
public static ValueTime fromTime(CastDataProvider provider, TimeZone timeZone, Time time)

Get or create a time value for the given time.

Parameters
provider:CastDataProvider

the cast information provider

timeZone:TimeZone

time zone, or null for default

time:Time

the time

Returns:ValueTime

the value

fromTimestampback to summary
public static ValueTimestamp fromTimestamp(CastDataProvider provider, TimeZone timeZone, Timestamp timestamp)

Get or create a timestamp value for the given timestamp.

Parameters
provider:CastDataProvider

the cast information provider

timeZone:TimeZone

time zone, or null for default

timestamp:Timestamp

the timestamp

Returns:ValueTimestamp

the value

fromTimestampback to summary
public static ValueTimestamp fromTimestamp(CastDataProvider provider, long ms, int nanos)

Get or create a timestamp value for the given date/time in millis.

Parameters
provider:CastDataProvider

the cast information provider

ms:long

the milliseconds

nanos:int

the nanoseconds

Returns:ValueTimestamp

the value

getMillisback to summary
public static long getMillis(CastDataProvider provider, TimeZone tz, long dateValue, long timeNanos)

Calculate the milliseconds since 1970-01-01 (UTC) for the given date and time (in the specified timezone).

Parameters
provider:CastDataProvider

the cast information provider

tz:TimeZone

the timezone of the parameters, or null for the default timezone

dateValue:long

date value

timeNanos:long

nanoseconds since midnight

Returns:long

the number of milliseconds (UTC)

getTimeZoneOffsetMillisback to summary
public static int getTimeZoneOffsetMillis(CastDataProvider provider, long ms)

Returns local time zone offset for a specified timestamp.

Parameters
provider:CastDataProvider

the cast information provider

ms:long

milliseconds since Epoch in UTC

Returns:int

local time zone offset

legacyClassToTypeback to summary
public static TypeInfo legacyClassToType(Class<?> clazz)

Get the type information for the given legacy Java class.

Parameters
clazz:Class<?>

the Java class

Returns:TypeInfo

the value type, or null if not supported

legacyObjectToValueback to summary
public static Value legacyObjectToValue(CastDataProvider session, Object x)

Convert a legacy Java object to a value.

Parameters
session:CastDataProvider

the session

x:Object

the value

Returns:Value

the value, or null if not supported

nanosFromLocalMillisback to summary
public static long nanosFromLocalMillis(long ms)

Convert a time in milliseconds in local time to the nanoseconds since midnight.

Parameters
ms:long

the milliseconds

Returns:long

the nanoseconds

timestampFromLocalMillisback to summary
private static ValueTimestamp timestampFromLocalMillis(long ms, int nanos)
toDateback to summary
public static Date toDate(CastDataProvider provider, TimeZone timeZone, Value value)

Get the date value converted to the specified time zone.

Parameters
provider:CastDataProvider

the cast information provider

timeZone:TimeZone

the target time zone

value:Value

the value to convert

Returns:Date

the date

toTimeback to summary
public static Time toTime(CastDataProvider provider, TimeZone timeZone, Value value)

Get the time value converted to the specified time zone.

Parameters
provider:CastDataProvider

the cast information provider

timeZone:TimeZone

the target time zone

value:Value

the value to convert

Returns:Time

the time

toTimestampback to summary
public static Timestamp toTimestamp(CastDataProvider provider, TimeZone timeZone, Value value)

Get the timestamp value converted to the specified time zone.

Parameters
provider:CastDataProvider

the cast information provider

timeZone:TimeZone

the target time zone

value:Value

the value to convert

Returns:Timestamp

the timestamp

valueToLegacyTypeback to summary
public static <T> T valueToLegacyType(Class<T> type, Value value, CastDataProvider provider)

Converts the specified value to an object of the specified legacy type.

Parameters
<T>
the type
type:Class<T>

the class

value:Value

the value

provider:CastDataProvider

the cast information provider

Returns:T

an instance of the specified class, or null if not supported

Annotations
@SuppressWarnings:unchecked