public class TimeUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
TimeUtil.CCompatibleTimeZone
Custom TimeZone implementations can be compatible with C libraries
regarding ambiguous and illegal timestamps.
|
static class |
TimeUtil.TimestampType |
static class |
TimeUtil.TimestampUnit |
| Constructor and Description |
|---|
TimeUtil() |
| Modifier and Type | Method and Description |
|---|---|
static SFTime |
getSFTime(String obj,
int scale)
Convert a time internal value (scaled number of seconds + fractional
seconds) into an SFTime.
|
static SFTimestamp |
getSFTimestamp(String timestampStr,
int scale,
TimeUtil.TimestampType internalColumnType,
long resultVersion,
TimeZone sessionTZ)
Convert a timestamp internal value (scaled number of seconds + fractional
seconds) into a SFTimestamp.
|
static SFTimestamp |
getSFTimestamp(String timestampStr,
TimeUtil.TimestampUnit unit,
int scale,
TimeUtil.TimestampType internalColumnType,
long resultVersion,
TimeZone sessionTZ)
Convert a timestamp internal value (scaled number of seconds + fractional
seconds or nanoseconds) into a SFTimestamp.
|
static int |
getYearAsInt(Calendar cal)
Extracts YEAR as a signed integer, taking care of BC.
|
static boolean |
isDSTAmbiguous(long dateInMs,
TimeZone tz)
Returns true if the specified instant corresponds to a wallclock time
that is "ambiguous" in the given timezone because of daylight saving
time rules.
|
static boolean |
isDSTIllegal(int era,
int year,
int month,
int dayOfMonth,
int dayOfWeek,
int millisecondWithinDay,
TimeZone tz)
Returns true if the specified instant is illegal in the current timezone
because of daylight saving time rules.
|
static Timestamp |
timestampFromNs(BigDecimal ns)
Converts the number of nanoseconds into a java.sql.Timestamp, if that is
possible.
|
public static Timestamp timestampFromNs(BigDecimal ns)
ns - a BigDecimal valuepublic static SFTimestamp getSFTimestamp(String timestampStr, int scale, TimeUtil.TimestampType internalColumnType, long resultVersion, TimeZone sessionTZ) throws IllegalArgumentException
timestampStr - timestamp objectscale - timestamp scaleinternalColumnType - snowflake timestamp typeresultVersion - For new result version, timestamp with timezone is formatted as
the seconds since epoch with fractional part in the decimal followed
by time zone index. E.g.: "123.456 1440". Here 123.456 is the * number
of seconds since epoch and 1440 is the timezone index.sessionTZ - session timezoneIllegalArgumentException - if timestampStr is an invalid timestamppublic static SFTimestamp getSFTimestamp(String timestampStr, TimeUtil.TimestampUnit unit, int scale, TimeUtil.TimestampType internalColumnType, long resultVersion, TimeZone sessionTZ) throws IllegalArgumentException
timestampStr - timestamp objectunit - IN_SECONDS or IN_NANOSECONDS, a unit of epoch time in timestampStrscale - timestamp scale for IN_SECONDS. Must be 0 for IN_NANOSECONDS.internalColumnType - snowflake timestamp typeresultVersion - For new result version, timestamp with timezone is formatted as
the seconds since epoch with fractional part in the decimal followed
by time zone index. E.g.: "123.456 1440". Here 123.456 is the * number
of seconds since epoch and 1440 is the timezone index.sessionTZ - session timezoneIllegalArgumentException - if timestampStr is an invalid timestamppublic static SFTime getSFTime(String obj, int scale) throws IllegalArgumentException
obj - time objectscale - time scaleIllegalArgumentException - if time is invalidpublic static boolean isDSTAmbiguous(long dateInMs,
TimeZone tz)
dateInMs - tz - public static boolean isDSTIllegal(int era,
int year,
int month,
int dayOfMonth,
int dayOfWeek,
int millisecondWithinDay,
TimeZone tz)
era - year - month - dayOfMonth - dayOfWeek - millisecondWithinDay - tz - public static int getYearAsInt(Calendar cal)
cal - calendar to extract YEAR fromCopyright © 2020. All rights reserved.