Convert the timestamp ts
from one timezone to another.
Convert the timestamp ts
from one timezone to another.
TODO: Because of DST, the conversion between UTC and human time is not exactly one-to-one mapping, the conversion here may return wrong result, we should make the timestamp timezone-aware.
Add date and year-month interval.
Add date and year-month interval. Returns a date value, expressed in days since 1.1.1970.
Returns the number of days since epoch from from java.
Returns the number of days since epoch from from java.sql.Date.
Returns the number of micros since epoch from java.
Returns the number of micros since epoch from java.sql.Timestamp.
Returns the number of microseconds since epoch from Julian day and nanoseconds in a day
Returns a timestamp of given timezone from utc timestamp, with the same string representation in their timezone.
Returns the 'day in year' value for the given date.
Returns the 'day in year' value for the given date. The date is expressed in days since 1.1.1970.
Returns the 'day of month' value for the given date.
Returns the 'day of month' value for the given date. The date is expressed in days since 1.1.1970.
Returns the hour value of a given timestamp value.
Returns the hour value of a given timestamp value. The timestamp is expressed in microseconds.
Returns last day of the month for the given date.
Returns last day of the month for the given date. The date is expressed in days since 1.1.1970.
Returns the minute value of a given timestamp value.
Returns the minute value of a given timestamp value. The timestamp is expressed in microseconds.
Returns the month value for the given date.
Returns the month value for the given date. The date is expressed in days since 1.1.1970. January is month 1.
Returns the first date which is later than startDate and is of the given dayOfWeek.
Returns the first date which is later than startDate and is of the given dayOfWeek. dayOfWeek is an integer ranges in [0, 6], and 0 is Thu, 1 is Fri, etc,.
Returns the quarter for the given date.
Returns the quarter for the given date. The date is expressed in days since 1.1.1970.
Returns the second value of a given timestamp value.
Returns the second value of a given timestamp value. The timestamp is expressed in microseconds.
Returns the year value for the given date.
Returns the year value for the given date. The date is expressed in days since 1.1.1970.
Returns number of months between time1 and time2.
Returns number of months between time1 and time2. time1 and time2 are expressed in microseconds since 1.1.1970.
If time1 and time2 having the same day of month, or both are the last day of month, it returns an integer (time under a day will be ignored).
Otherwise, the difference is calculated based on 31 days per month, and rounding to 8 digits.
Returns the truncate level, could be TRUNC_YEAR, TRUNC_MONTH, or TRUNC_INVALID, TRUNC_INVALID means unsupported truncate level.
Split date (expressed in days since 1.
Split date (expressed in days since 1.1.1970) into four fields: year, month (Jan is Month 1), dayInMonth, daysToMonthEnd (0 if it's last day of month).
Parses a given UTF8 date string to the corresponding a corresponding Int value.
Parses a given UTF8 date string to the corresponding a corresponding Int value. The return type is Option in order to distinguish between 0 and null. The following formats are allowed:
yyyy
,
yyyy-[m]m
yyyy-[m]m-[d]d
yyyy-[m]m-[d]d
yyyy-[m]m-[d]d *
yyyy-[m]m-[d]dT*
Parses a given UTF8 date string to the corresponding a corresponding Long value.
Parses a given UTF8 date string to the corresponding a corresponding Long value. The return type is Option in order to distinguish between 0L and null. The following formats are allowed:
yyyy
yyyy-[m]m
yyyy-[m]m-[d]d
yyyy-[m]m-[d]d
yyyy-[m]m-[d]d [h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]
yyyy-[m]m-[d]d [h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]Z
yyyy-[m]m-[d]d [h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]-[h]h:[m]m
yyyy-[m]m-[d]d [h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]+[h]h:[m]m
yyyy-[m]m-[d]dT[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]
yyyy-[m]m-[d]dT[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]Z
yyyy-[m]m-[d]dT[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]-[h]h:[m]m
yyyy-[m]m-[d]dT[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]+[h]h:[m]m
[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]
[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]Z
[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]-[h]h:[m]m
[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]+[h]h:[m]m
T[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]
T[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]Z
T[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]-[h]h:[m]m
T[h]h:[m]m:[s]s.[ms][ms][ms][us][us][us]+[h]h:[m]m
Add timestamp and full interval.
Add timestamp and full interval. Returns a timestamp value, expressed in microseconds since 1.1.1970 00:00:00.
Returns a java.
Returns a java.sql.Date from number of days since epoch.
Returns a java.
Returns a java.sql.Timestamp from number of micros since epoch.
Returns Julian day and nanoseconds in a day from the number of microseconds
Returns Julian day and nanoseconds in a day from the number of microseconds
Note: support timestamp since 4717 BC (without negative nanoseconds, compatible with Hive).
Returns a utc timestamp from a given timestamp from a given timezone, with the same string representation in their timezone.
Returns the trunc date from original date and trunc level.
Returns the trunc date from original date and trunc level.
Trunc level should be generated using parseTruncLevel()
, should only be 1 or 2.
Helper functions for converting between internal and external date and time representations. Dates are exposed externally as java.sql.Date and are represented internally as the number of dates since the Unix epoch (1970-01-01). Timestamps are exposed externally as java.sql.Timestamp and are stored internally as longs, which are capable of storing timestamps with 100 nanosecond precision.