Object

org.apache.spark.sql.catalyst.util

DateTimeUtils

Related Doc: package util

Permalink

object DateTimeUtils

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.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. DateTimeUtils
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. type SQLDate = Int

    Permalink
  2. type SQLTimestamp = Long

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final val JULIAN_DAY_OF_EPOCH: Int(2440588)

    Permalink
  5. final val MICROS_PER_DAY: Long

    Permalink
  6. final val MICROS_PER_SECOND: Long(1000000L)

    Permalink
  7. final val MILLIS_PER_DAY: Long

    Permalink
  8. final val NANOS_PER_SECOND: Long

    Permalink
  9. final val SECONDS_PER_DAY: Long

    Permalink
  10. final val YearZero: Int(-17999)

    Permalink
  11. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  12. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  13. def dateAddMonths(days: SQLDate, months: Int): SQLDate

    Permalink

    Add date and year-month interval.

    Add date and year-month interval. Returns a date value, expressed in days since 1.1.1970.

  14. def dateToString(days: SQLDate): String

    Permalink
  15. final val daysIn400Years: Int

    Permalink
  16. def daysToMillis(days: SQLDate): Long

    Permalink
  17. lazy val defaultTimeZone: TimeZone

    Permalink
  18. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  19. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  20. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  21. def fromJavaDate(date: Date): SQLDate

    Permalink

    Returns the number of days since epoch from from java.sql.Date.

  22. def fromJavaTimestamp(t: Timestamp): SQLTimestamp

    Permalink

    Returns the number of micros since epoch from java.sql.Timestamp.

  23. def fromJulianDay(day: Int, nanoseconds: Long): SQLTimestamp

    Permalink

    Returns the number of microseconds since epoch from Julian day and nanoseconds in a day

  24. def fromUTCTime(time: SQLTimestamp, timeZone: String): SQLTimestamp

    Permalink

    Returns a timestamp of given timezone from utc timestamp, with the same string representation in their timezone.

  25. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  26. def getDayInYear(date: SQLDate): Int

    Permalink

    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.

  27. def getDayOfMonth(date: SQLDate): Int

    Permalink

    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.

  28. def getDayOfWeekFromString(string: UTF8String): Int

    Permalink
  29. def getHours(microsec: SQLTimestamp): Int

    Permalink

    Returns the hour value of a given timestamp value.

    Returns the hour value of a given timestamp value. The timestamp is expressed in microseconds.

  30. def getLastDayOfMonth(date: SQLDate): SQLDate

    Permalink

    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.

  31. def getMinutes(microsec: SQLTimestamp): Int

    Permalink

    Returns the minute value of a given timestamp value.

    Returns the minute value of a given timestamp value. The timestamp is expressed in microseconds.

  32. def getMonth(date: SQLDate): Int

    Permalink

    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.

  33. def getNextDateForDayOfWeek(startDate: SQLDate, dayOfWeek: Int): SQLDate

    Permalink

    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,.

  34. def getQuarter(date: SQLDate): Int

    Permalink

    Returns the quarter for the given date.

    Returns the quarter for the given date. The date is expressed in days since 1.1.1970.

  35. def getSeconds(microsec: SQLTimestamp): Int

    Permalink

    Returns the second value of a given timestamp value.

    Returns the second value of a given timestamp value. The timestamp is expressed in microseconds.

  36. def getYear(date: SQLDate): Int

    Permalink

    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.

  37. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  38. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  39. def millisToDays(millisUtc: Long): SQLDate

    Permalink
  40. def monthsBetween(time1: SQLTimestamp, time2: SQLTimestamp): Double

    Permalink

    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.

  41. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  42. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  43. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  44. def parseTruncLevel(format: UTF8String): Int

    Permalink

    Returns the truncate level, could be TRUNC_YEAR, TRUNC_MONTH, or TRUNC_INVALID, TRUNC_INVALID means unsupported truncate level.

  45. def splitDate(date: SQLDate): (Int, Int, Int, Int)

    Permalink

    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).

  46. def stringToDate(s: UTF8String): Option[SQLDate]

    Permalink

    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*

  47. def stringToTime(s: String): Date

    Permalink
  48. def stringToTimestamp(s: UTF8String): Option[SQLTimestamp]

    Permalink

    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

  49. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  50. def timestampAddInterval(start: SQLTimestamp, months: Int, microseconds: Long): SQLTimestamp

    Permalink

    Add timestamp and full interval.

    Add timestamp and full interval. Returns a timestamp value, expressed in microseconds since 1.1.1970 00:00:00.

  51. def timestampToString(us: SQLTimestamp): String

    Permalink
  52. final val to2001: Int(-11323)

    Permalink
  53. def toJavaDate(daysSinceEpoch: SQLDate): Date

    Permalink

    Returns a java.sql.Date from number of days since epoch.

  54. def toJavaTimestamp(us: SQLTimestamp): Timestamp

    Permalink

    Returns a java.sql.Timestamp from number of micros since epoch.

  55. def toJulianDay(us: SQLTimestamp): (Int, Long)

    Permalink

    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).

  56. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  57. def toUTCTime(time: SQLTimestamp, timeZone: String): SQLTimestamp

    Permalink

    Returns a utc timestamp from a given timestamp from a given timezone, with the same string representation in their timezone.

  58. final val toYearZero: Int

    Permalink
  59. def truncDate(d: SQLDate, level: Int): SQLDate

    Permalink

    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.

  60. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  61. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  62. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped