com.ibm.ia.time

Class CalendarDuration

  • java.lang.Object
    • com.ibm.ia.time.CalendarDuration
  • All Implemented Interfaces:
    java.io.Serializable, java.time.temporal.TemporalAmount


    public class CalendarDuration
    extends java.lang.Object
    implements java.time.temporal.TemporalAmount, java.io.Serializable

    A calendar duration represents a number of years, months, days, hours, and a number of minutes and seconds in the range 0 - 59.

    See Also:
    Serialized Form
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      java.time.temporal.Temporal addTo(java.time.temporal.Temporal temporal)
      Returns a temporal object obtained by adding this calendar duration to the specified temporal object.
      boolean equals(java.lang.Object o) 
      int getDays()
      Returns the number of days of the calendar duration.
      static CalendarDuration getDuration(java.time.ZonedDateTime startWithNano, java.time.ZonedDateTime endWithNano, java.time.ZoneId zone)
      Returns the calendar duration that results into the later time point if added to the earlier time point.
      int getHours()
      Returns the number of hours of the calendar duration.
      int getMinutes()
      Returns the number of minutes of the calendar duration, which is in the range 0 - 59.
      int getMonths()
      Returns the number of months of the calendar duration.
      int getSeconds()
      Returns the number of seconds of the calendar duration, which is in the range 0 - 59.
      int getYears()
      Returns the number of years of the calendar duration.
      int hashCode() 
      CalendarDuration multipliedBy(int scalar)
      Returns a new calendar duration having all units of the given calendar duration multiplied by a scalar.
      static CalendarDuration of(java.time.Duration duration)
      Returns a calendar duration for the given instance of class java.time.Duration which represents a number of hours and a number of minutes and seconds in the range 0 - 59.
      static CalendarDuration of(java.time.Period period)
      Returns a calendar duration for the given instance of class java.time.Period which represents a number of years, months, and days.
      static CalendarDuration of(java.time.Period period, java.time.Duration duration)
      Returns a calendar duration for the given instance of class java.time.Period which represents a number of years, months, number of days as well as the given instance of class java.time.Duration which represents a number of hours and a number of minutes and seconds in the range 0 - 59.
      static CalendarDuration parse(java.lang.String text)
      Transforms a textual representation of a duration in ISO 8601-format into a calendar duration.
      java.time.temporal.Temporal subtractFrom(java.time.temporal.Temporal temporal)
      Returns a temporal object obtained by subtracting this calendar duration from the specified temporal object.
      java.lang.String toString()
      Transforms a calendar duration into a textual representation of a duration in ISO 8601-format.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.time.temporal.TemporalAmount

        get, getUnits
    • Method Detail

      • of

        public static CalendarDuration of(java.time.Duration duration)

        Returns a calendar duration for the given instance of class java.time.Duration which represents a number of hours and a number of minutes and seconds in the range 0 - 59.

      • of

        public static CalendarDuration of(java.time.Period period)

        Returns a calendar duration for the given instance of class java.time.Period which represents a number of years, months, and days.

      • of

        public static CalendarDuration of(java.time.Period period,
                          java.time.Duration duration)

        Returns a calendar duration for the given instance of class java.time.Period which represents a number of years, months, number of days as well as the given instance of class java.time.Duration which represents a number of hours and a number of minutes and seconds in the range 0 - 59.

      • addTo

        public java.time.temporal.Temporal addTo(java.time.temporal.Temporal temporal)

        Returns a temporal object obtained by adding this calendar duration to the specified temporal object.

        Specified by:
        addTo in interface java.time.temporal.TemporalAmount
      • subtractFrom

        public java.time.temporal.Temporal subtractFrom(java.time.temporal.Temporal temporal)

        Returns a temporal object obtained by subtracting this calendar duration from the specified temporal object.

        Specified by:
        subtractFrom in interface java.time.temporal.TemporalAmount
      • getDays

        public int getDays()

        Returns the number of days of the calendar duration.

      • getSeconds

        public int getSeconds()

        Returns the number of seconds of the calendar duration, which is in the range 0 - 59.

      • getMinutes

        public int getMinutes()

        Returns the number of minutes of the calendar duration, which is in the range 0 - 59.

      • getHours

        public int getHours()

        Returns the number of hours of the calendar duration.

      • getMonths

        public int getMonths()

        Returns the number of months of the calendar duration.

      • getYears

        public int getYears()

        Returns the number of years of the calendar duration.

      • getDuration

        public static CalendarDuration getDuration(java.time.ZonedDateTime startWithNano,
                                   java.time.ZonedDateTime endWithNano,
                                   java.time.ZoneId zone)

        Returns the calendar duration that results into the later time point if added to the earlier time point.

      • parse

        public static CalendarDuration parse(java.lang.String text)

        Transforms a textual representation of a duration in ISO 8601-format into a calendar duration.

      • toString

        public java.lang.String toString()

        Transforms a calendar duration into a textual representation of a duration in ISO 8601-format.

        Overrides:
        toString in class java.lang.Object
      • multipliedBy

        public CalendarDuration multipliedBy(int scalar)

        Returns a new calendar duration having all units of the given calendar duration multiplied by a scalar.

      • equals

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

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object

© Copyright IBM 2016