org.apache.spark.sql.catalyst.util

DateTimeUtils

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 microsecond precision.

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

Type Members

  1. type SQLDate = Int

  2. type SQLTimestamp = Long

Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final val JULIAN_DAY_OF_EPOCH: Int(2440588)

  7. final val MICROS_PER_DAY: Long

  8. final val MICROS_PER_SECOND: Long(1000000L)

  9. final val MILLIS_PER_DAY: Long

  10. final val MILLIS_PER_SECOND: Long(1000L)

  11. final val MonthOf31Days: Set[Int]

  12. final val NANOS_PER_SECOND: Long

  13. final val SECONDS_PER_DAY: Long

  14. val TIMEZONE_OPTION: String

  15. final val TimeZoneGMT: TimeZone

  16. final val YearZero: Int(-17999)

  17. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  18. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. def convertTz(ts: SQLTimestamp, fromZone: TimeZone, toZone: TimeZone): SQLTimestamp

    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.

  20. def dateAddMonths(days: SQLDate, months: Int): SQLDate

    Add date and year-month interval.

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

  21. def dateToString(days: SQLDate): String

  22. final val daysIn400Years: Int

  23. def daysToMillis(days: SQLDate, timeZone: TimeZone): Long

  24. def daysToMillis(days: SQLDate): Long

  25. def defaultTimeZone(): TimeZone

  26. final def eq(arg0: AnyRef): Boolean

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

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

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

    Returns the number of days since epoch from java.

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

  30. def fromJavaTimestamp(t: Timestamp): SQLTimestamp

    Returns the number of micros since epoch from java.

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

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

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

  32. def fromMillis(millis: Long): SQLTimestamp

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

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

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

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

    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.

  36. def getDayOfMonth(date: SQLDate): Int

    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.

  37. def getDayOfWeekFromString(string: UTF8String): Int

  38. def getHours(microsec: SQLTimestamp, timeZone: TimeZone): Int

    Returns the hour value of a given timestamp value.

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

  39. def getHours(microsec: SQLTimestamp): Int

    Returns the hour value of a given timestamp value.

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

  40. def getLastDayOfMonth(date: SQLDate): SQLDate

    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.

  41. def getMinutes(microsec: SQLTimestamp, timeZone: TimeZone): Int

    Returns the minute value of a given timestamp value.

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

  42. def getMinutes(microsec: SQLTimestamp): Int

    Returns the minute value of a given timestamp value.

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

  43. def getMonth(date: SQLDate): Int

    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.

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

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

  45. def getQuarter(date: SQLDate): Int

    Returns the quarter for the given date.

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

  46. def getSeconds(microsec: SQLTimestamp, timeZone: TimeZone): Int

    Returns the second value of a given timestamp value.

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

  47. def getSeconds(microsec: SQLTimestamp): Int

    Returns the second value of a given timestamp value.

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

  48. def getThreadLocalDateFormat(): DateFormat

  49. def getThreadLocalTimestampFormat(timeZone: TimeZone): DateFormat

  50. def getTimeZone(timeZoneId: String): TimeZone

  51. def getYear(date: SQLDate): Int

    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.

  52. def hashCode(): Int

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

    Definition Classes
    Any
  54. def millisToDays(millisUtc: Long, timeZone: TimeZone): SQLDate

  55. def millisToDays(millisUtc: Long): SQLDate

  56. def monthsBetween(time1: SQLTimestamp, time2: SQLTimestamp, timeZone: TimeZone): Double

    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.

  57. def monthsBetween(time1: SQLTimestamp, time2: SQLTimestamp): Double

    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.

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

    Definition Classes
    AnyRef
  59. def newDateFormat(formatString: String, timeZone: TimeZone): DateFormat

  60. final def notify(): Unit

    Definition Classes
    AnyRef
  61. final def notifyAll(): Unit

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

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

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

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

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

    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*

  65. def stringToTime(s: String): Date

    Annotations
    @tailrec()
  66. def stringToTimestamp(s: UTF8String, timeZone: TimeZone): Option[SQLTimestamp]

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

    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

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

    Definition Classes
    AnyRef
  69. def timestampAddInterval(start: SQLTimestamp, months: Int, microseconds: Long, timeZone: TimeZone): SQLTimestamp

    Add timestamp and full interval.

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

  70. def timestampAddInterval(start: SQLTimestamp, months: Int, microseconds: Long): SQLTimestamp

    Add timestamp and full interval.

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

  71. def timestampToString(us: SQLTimestamp, timeZone: TimeZone): String

  72. def timestampToString(us: SQLTimestamp): String

  73. final val to2001: Int(-11323)

  74. def toJavaDate(daysSinceEpoch: SQLDate): Date

    Returns a java.

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

  75. def toJavaTimestamp(us: SQLTimestamp): Timestamp

    Returns a java.

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

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

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

  77. def toMillis(us: SQLTimestamp): Long

  78. def toString(): String

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

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

  80. final val toYearZero: Int

  81. def truncDate(d: SQLDate, level: Int): SQLDate

    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.

  82. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped