public final class LegacyDateTimeUtils
extends java.lang.Object
Date, Time, and Timestamp
classes.| Modifier and Type | Field and Description |
|---|---|
static java.sql.Date |
PROLEPTIC_GREGORIAN_CHANGE
Gregorian change date for a
GregorianCalendar that
represents a proleptic Gregorian calendar. |
static java.util.TimeZone |
UTC
UTC time zone.
|
| Modifier and Type | Method and Description |
|---|---|
static long |
dateValueFromLocalMillis(long ms)
Convert a local datetime in millis to an encoded date.
|
static ValueDate |
fromDate(CastDataProvider provider,
java.util.TimeZone timeZone,
java.sql.Date date)
Get or create a date value for the given date.
|
static ValueTime |
fromTime(CastDataProvider provider,
java.util.TimeZone timeZone,
java.sql.Time time)
Get or create a time value for the given time.
|
static ValueTimestamp |
fromTimestamp(CastDataProvider provider,
long ms,
int nanos)
Get or create a timestamp value for the given date/time in millis.
|
static ValueTimestamp |
fromTimestamp(CastDataProvider provider,
java.util.TimeZone timeZone,
java.sql.Timestamp timestamp)
Get or create a timestamp value for the given timestamp.
|
static long |
getMillis(CastDataProvider provider,
java.util.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 int |
getTimeZoneOffsetMillis(CastDataProvider provider,
long ms)
Returns local time zone offset for a specified timestamp.
|
static TypeInfo |
legacyClassToType(java.lang.Class<?> clazz)
Get the type information for the given legacy Java class.
|
static Value |
legacyObjectToValue(CastDataProvider session,
java.lang.Object x)
Convert a legacy Java object to a value.
|
static long |
nanosFromLocalMillis(long ms)
Convert a time in milliseconds in local time to the nanoseconds since
midnight.
|
static java.sql.Date |
toDate(CastDataProvider provider,
java.util.TimeZone timeZone,
Value value)
Get the date value converted to the specified time zone.
|
static java.sql.Time |
toTime(CastDataProvider provider,
java.util.TimeZone timeZone,
Value value)
Get the time value converted to the specified time zone.
|
static java.sql.Timestamp |
toTimestamp(CastDataProvider provider,
java.util.TimeZone timeZone,
Value value)
Get the timestamp value converted to the specified time zone.
|
static <T> T |
valueToLegacyType(java.lang.Class<T> type,
Value value,
CastDataProvider provider)
Converts the specified value to an object of the specified legacy type.
|
public static final java.sql.Date PROLEPTIC_GREGORIAN_CHANGE
GregorianCalendar that
represents a proleptic Gregorian calendar.public static final java.util.TimeZone UTC
public static ValueDate fromDate(CastDataProvider provider, java.util.TimeZone timeZone, java.sql.Date date)
provider - the cast information providertimeZone - time zone, or null for defaultdate - the datepublic static ValueTime fromTime(CastDataProvider provider, java.util.TimeZone timeZone, java.sql.Time time)
provider - the cast information providertimeZone - time zone, or null for defaulttime - the timepublic static ValueTimestamp fromTimestamp(CastDataProvider provider, java.util.TimeZone timeZone, java.sql.Timestamp timestamp)
provider - the cast information providertimeZone - time zone, or null for defaulttimestamp - the timestamppublic static ValueTimestamp fromTimestamp(CastDataProvider provider, long ms, int nanos)
provider - the cast information providerms - the millisecondsnanos - the nanosecondspublic static long dateValueFromLocalMillis(long ms)
ms - the millisecondspublic static long nanosFromLocalMillis(long ms)
ms - the millisecondspublic static java.sql.Date toDate(CastDataProvider provider, java.util.TimeZone timeZone, Value value)
provider - the cast information providertimeZone - the target time zonevalue - the value to convertpublic static java.sql.Time toTime(CastDataProvider provider, java.util.TimeZone timeZone, Value value)
provider - the cast information providertimeZone - the target time zonevalue - the value to convertpublic static java.sql.Timestamp toTimestamp(CastDataProvider provider, java.util.TimeZone timeZone, Value value)
provider - the cast information providertimeZone - the target time zonevalue - the value to convertpublic static long getMillis(CastDataProvider provider, java.util.TimeZone tz, long dateValue, long timeNanos)
provider - the cast information providertz - the timezone of the parameters, or null for the default
timezonedateValue - date valuetimeNanos - nanoseconds since midnightpublic static int getTimeZoneOffsetMillis(CastDataProvider provider, long ms)
provider - the cast information providerms - milliseconds since Epoch in UTCpublic static Value legacyObjectToValue(CastDataProvider session, java.lang.Object x)
session - the sessionx - the valuenull if not supportedpublic static <T> T valueToLegacyType(java.lang.Class<T> type,
Value value,
CastDataProvider provider)
T - the typetype - the classvalue - the valueprovider - the cast information providernull if not supportedpublic static TypeInfo legacyClassToType(java.lang.Class<?> clazz)
clazz - the Java classnull if not supported