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 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
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 MILLIS_PER_SECOND: Long(1000L)

    Permalink
  9. final val MonthOf31Days: Set[Int]

    Permalink
  10. final val NANOS_PER_SECOND: Long

    Permalink
  11. final val SECONDS_PER_DAY: Long

    Permalink
  12. val TIMEZONE_OPTION: String

    Permalink
  13. final val TimeZoneGMT: TimeZone

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

    Permalink
  15. final def asInstanceOf[T0]: T0

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

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

    Permalink

    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.

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

  19. def dateToString(days: SQLDate): String

    Permalink
  20. final val daysIn400Years: Int

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

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

    Permalink
  23. def defaultTimeZone(): TimeZone

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

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

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

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

    Permalink

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

  28. def fromJavaTimestamp(t: Timestamp): SQLTimestamp

    Permalink

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

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

    Permalink

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

  30. def fromMillis(millis: Long): SQLTimestamp

    Permalink
  31. 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.

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

    Permalink
    Definition Classes
    AnyRef → Any
  33. 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.

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

  35. def getDayOfWeekFromString(string: UTF8String): Int

    Permalink
  36. def getHours(microsec: SQLTimestamp, timeZone: TimeZone): 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.

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

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

  39. def getMinutes(microsec: SQLTimestamp, timeZone: TimeZone): 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.

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

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

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

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

  44. def getSeconds(microsec: SQLTimestamp, timeZone: TimeZone): 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.

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

  46. def getThreadLocalDateFormat(): DateFormat

    Permalink
  47. def getThreadLocalTimestampFormat(timeZone: TimeZone): DateFormat

    Permalink
  48. def getTimeZone(timeZoneId: String): TimeZone

    Permalink
  49. 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.

  50. def hashCode(): Int

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

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

    Permalink
  53. def millisToDays(millisUtc: Long): SQLDate

    Permalink
  54. def monthsBetween(time1: SQLTimestamp, time2: SQLTimestamp, timeZone: TimeZone): 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.

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

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

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

    Permalink
  58. final def notify(): Unit

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

    Permalink
    Definition Classes
    AnyRef
  60. 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.

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

  62. 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*

  63. def stringToTime(s: String): Date

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

    Permalink
  65. 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

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

    Permalink
    Definition Classes
    AnyRef
  67. def timestampAddInterval(start: SQLTimestamp, months: Int, microseconds: Long, timeZone: TimeZone): 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.

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

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

    Permalink
  70. def timestampToString(us: SQLTimestamp): String

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

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

    Permalink

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

  73. def toJavaTimestamp(us: SQLTimestamp): Timestamp

    Permalink

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

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

  75. def toMillis(us: SQLTimestamp): Long

    Permalink
  76. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  77. 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.

  78. final val toYearZero: Int

    Permalink
  79. 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.

  80. final def wait(): Unit

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

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

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

Inherited from AnyRef

Inherited from Any

Ungrouped