Package org.h2.util
Class LegacyDateTimeUtils
java.lang.Object
org.h2.util.LegacyDateTimeUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DateGregorian change date for aGregorianCalendarthat represents a proleptic Gregorian calendar.static final TimeZoneUTC time zone. -
Method Summary
Modifier and TypeMethodDescriptionstatic longdateValueFromLocalMillis(long ms) Convert a local datetime in millis to an encoded date.static ValueDatefromDate(CastDataProvider provider, TimeZone timeZone, Date date) Get or create a date value for the given date.static ValueTimefromTime(CastDataProvider provider, TimeZone timeZone, Time time) Get or create a time value for the given time.static ValueTimestampfromTimestamp(CastDataProvider provider, long ms, int nanos) Get or create a timestamp value for the given date/time in millis.static ValueTimestampfromTimestamp(CastDataProvider provider, TimeZone timeZone, Timestamp timestamp) Get or create a timestamp value for the given timestamp.static longgetMillis(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).static intgetTimeZoneOffsetMillis(CastDataProvider provider, long ms) Returns local time zone offset for a specified timestamp.static TypeInfolegacyClassToType(Class<?> clazz) Get the type information for the given legacy Java class.static ValuelegacyObjectToValue(CastDataProvider session, Object x) Convert a legacy Java object to a value.static longnanosFromLocalMillis(long ms) Convert a time in milliseconds in local time to the nanoseconds since midnight.static DatetoDate(CastDataProvider provider, TimeZone timeZone, Value value) Get the date value converted to the specified time zone.static TimetoTime(CastDataProvider provider, TimeZone timeZone, Value value) Get the time value converted to the specified time zone.static TimestamptoTimestamp(CastDataProvider provider, TimeZone timeZone, Value value) Get the timestamp value converted to the specified time zone.static <T> TvalueToLegacyType(Class<T> type, Value value, CastDataProvider provider) Converts the specified value to an object of the specified legacy type.
-
Field Details
-
PROLEPTIC_GREGORIAN_CHANGE
Gregorian change date for aGregorianCalendarthat represents a proleptic Gregorian calendar. -
UTC
UTC time zone.
-
-
Method Details
-
fromDate
Get or create a date value for the given date.- Parameters:
provider- the cast information providertimeZone- time zone, ornullfor defaultdate- the date- Returns:
- the value
-
fromTime
Get or create a time value for the given time.- Parameters:
provider- the cast information providertimeZone- time zone, ornullfor defaulttime- the time- Returns:
- the value
-
fromTimestamp
public static ValueTimestamp fromTimestamp(CastDataProvider provider, TimeZone timeZone, Timestamp timestamp) Get or create a timestamp value for the given timestamp.- Parameters:
provider- the cast information providertimeZone- time zone, ornullfor defaulttimestamp- the timestamp- Returns:
- the value
-
fromTimestamp
Get or create a timestamp value for the given date/time in millis.- Parameters:
provider- the cast information providerms- the millisecondsnanos- the nanoseconds- Returns:
- the value
-
dateValueFromLocalMillis
public static long dateValueFromLocalMillis(long ms) Convert a local datetime in millis to an encoded date.- Parameters:
ms- the milliseconds- Returns:
- the date value
-
nanosFromLocalMillis
public static long nanosFromLocalMillis(long ms) Convert a time in milliseconds in local time to the nanoseconds since midnight.- Parameters:
ms- the milliseconds- Returns:
- the nanoseconds
-
toDate
Get the date value converted to the specified time zone.- Parameters:
provider- the cast information providertimeZone- the target time zonevalue- the value to convert- Returns:
- the date
-
toTime
Get the time value converted to the specified time zone.- Parameters:
provider- the cast information providertimeZone- the target time zonevalue- the value to convert- Returns:
- the time
-
toTimestamp
Get the timestamp value converted to the specified time zone.- Parameters:
provider- the cast information providertimeZone- the target time zonevalue- the value to convert- Returns:
- the timestamp
-
getMillis
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- the cast information providertz- the timezone of the parameters, or null for the default timezonedateValue- date valuetimeNanos- nanoseconds since midnight- Returns:
- the number of milliseconds (UTC)
-
getTimeZoneOffsetMillis
Returns local time zone offset for a specified timestamp.- Parameters:
provider- the cast information providerms- milliseconds since Epoch in UTC- Returns:
- local time zone offset
-
legacyObjectToValue
Convert a legacy Java object to a value.- Parameters:
session- the sessionx- the value- Returns:
- the value, or
nullif not supported
-
valueToLegacyType
Converts the specified value to an object of the specified legacy type.- Type Parameters:
T- the type- Parameters:
type- the classvalue- the valueprovider- the cast information provider- Returns:
- an instance of the specified class, or
nullif not supported
-
legacyClassToType
Get the type information for the given legacy Java class.- Parameters:
clazz- the Java class- Returns:
- the value type, or
nullif not supported
-