Class CalendarInterval

Object
org.apache.spark.unsafe.types.CalendarInterval
All Implemented Interfaces:
Serializable

@Unstable public final class CalendarInterval extends Object implements Serializable
The class representing calendar intervals. The calendar interval is stored internally in three components:
  • an integer value representing the number of `months` in this interval,
  • an integer value representing the number of `days` in this interval,
  • a long value representing the number of `microseconds` in this interval.
The `months` and `days` are not units of time with a constant length (unlike hours, seconds), so they are two separated fields from microseconds. One month may be equal to 28, 29, 30 or 31 days and one day may be equal to 23, 24 or 25 hours (daylight saving).
Since:
3.0.0
See Also:
  • Field Details

    • months

      public final int months
    • days

      public final int days
    • microseconds

      public final long microseconds
  • Constructor Details

    • CalendarInterval

      public CalendarInterval(int months, int days, long microseconds)
  • Method Details

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • extractAsPeriod

      public Period extractAsPeriod()
      Extracts the date part of the interval.
      Returns:
      an instance of java.time.Period based on the months and days fields of the given interval, not null.
    • extractAsDuration

      public Duration extractAsDuration()
      Extracts the time part of the interval.
      Returns:
      an instance of java.time.Duration based on the microseconds field of the given interval, not null.
      Throws:
      ArithmeticException - if a numeric overflow occurs