Class TemporalInterval

    • Constructor Detail

      • TemporalInterval

        public TemporalInterval​(int years,
                                int months,
                                int days,
                                int hours,
                                int minutes,
                                int seconds)
        Constructs a temporal interval with the given temporal amounts.
        Parameters:
        years - The years
        months - The months
        days - The days
        hours - The hours
        minutes - The minutes
        seconds - The seconds
    • Method Detail

      • getYears

        public int getYears()
        Returns the years.
        Returns:
        the years
      • getMonths

        public int getMonths()
        Returns the months.
        Returns:
        the months
      • getDays

        public int getDays()
        Returns the days.
        Returns:
        the days
      • getHours

        public int getHours()
        Returns the hours.
        Returns:
        the hours
      • getMinutes

        public int getMinutes()
        Returns the minutes.
        Returns:
        the minutes
      • getSeconds

        public int getSeconds()
        Returns the seconds.
        Returns:
        the seconds
      • equals

        public boolean equals​(Object o)
        Returns true if all amounts are equal to the amounts of the other interval.
        Overrides:
        equals in class Object
        Parameters:
        o - The other interval
        Returns:
        true if equal, false otherwise
      • hashCode

        public int hashCode()
        Returns the hash code based on the individual amounts.
        Overrides:
        hashCode in class Object
        Returns:
        the hash code
      • toString

        public String toString()
        The format is (Y YEARS )?(m MONTHS )?(d DAYS )?(h HOURS )?(m MINUTES )?s SECONDS.
        Overrides:
        toString in class Object
        Returns:
        the string representation of the interval
      • add

        public TemporalInterval add​(TemporalInterval interval2)
        Adds the given interval to this and returns a new interval.
        Parameters:
        interval2 - The interval to add
        Returns:
        A new interval representing the sum of this and the other interval
      • subtract

        public TemporalInterval subtract​(TemporalInterval interval2)
        Subtracts the given interval from this and returns a new interval.
        Parameters:
        interval2 - The interval to subtract
        Returns:
        A new interval representing the sum of this subtracted by the other interval
      • add

        public Instant add​(Instant instant)
        Adds this interval to the given instant producing a new instant.
        Parameters:
        instant - The instant to which to add this interval.
        Returns:
        A new instant representing the sum of the given instant plus this interval
      • subtract

        public Instant subtract​(Instant instant)
        Subtract this interval from the given instant producing a new instant.
        Parameters:
        instant - The instant from which to subtract this interval.
        Returns:
        A new instant representing the sum of the given instant subtracted by this interval
      • add

        public LocalTime add​(LocalTime localTime)
        Adds this interval to the given local time producing a new local time.
        Parameters:
        localTime - The local time to which to add this interval.
        Returns:
        A new local time representing the sum of the given local time plus this interval
      • subtract

        public LocalTime subtract​(LocalTime localTime)
        Subtract this interval from the given local time producing a new local time.
        Parameters:
        localTime - The local time from which to subtract this interval.
        Returns:
        A new local time representing the sum of the given local time subtracted by this interval