Class Interval


  • public class Interval
    extends Object
    Postgres Interval is date and time based such as 120 years 3 months 332 days 20 hours 20 minutes 20.999999 seconds
    Author:
    Emad Alblueshi
    • Constructor Detail

      • Interval

        public Interval()
      • Interval

        public Interval​(int years,
                        int months,
                        int days,
                        int hours,
                        int minutes,
                        int seconds,
                        int microseconds)
      • Interval

        public Interval​(int years,
                        int months,
                        int days,
                        int hours,
                        int minutes,
                        int seconds)
      • Interval

        public Interval​(int years,
                        int months,
                        int days,
                        int hours,
                        int minutes)
      • Interval

        public Interval​(int years,
                        int months,
                        int days,
                        int hours)
      • Interval

        public Interval​(int years,
                        int months,
                        int days)
      • Interval

        public Interval​(int years,
                        int months)
      • Interval

        public Interval​(int years)
    • Method Detail

      • of

        public static Interval of​(int years,
                                  int months,
                                  int days,
                                  int hours,
                                  int minutes,
                                  int seconds,
                                  int microseconds)
      • of

        public static Interval of​(int years,
                                  int months,
                                  int days,
                                  int hours,
                                  int minutes,
                                  int seconds)
      • of

        public static Interval of​(int years,
                                  int months,
                                  int days,
                                  int hours,
                                  int minutes)
      • of

        public static Interval of​(int years,
                                  int months,
                                  int days,
                                  int hours)
      • of

        public static Interval of​(int years,
                                  int months,
                                  int days)
      • of

        public static Interval of​(int years,
                                  int months)
      • of

        public static Interval of​(int years)
      • of

        public static Interval of​(java.time.Duration duration)
        Creates an instance from the given Duration.

        The conversion algorithm assumes a year lasts 12 months and a month lasts 30 days, as Postgres does and ISO 8601 suggests.

        Parameters:
        duration - the value to convert
        Returns:
        a new instance of Interval
      • years

        public Interval years​(int years)
      • months

        public Interval months​(int months)
      • days

        public Interval days​(int days)
      • hours

        public Interval hours​(int hours)
      • minutes

        public Interval minutes​(int minutes)
      • seconds

        public Interval seconds​(int seconds)
      • microseconds

        public Interval microseconds​(int microseconds)
      • getYears

        public int getYears()
      • setYears

        public void setYears​(int years)
      • getMonths

        public int getMonths()
      • setMonths

        public void setMonths​(int months)
      • getDays

        public int getDays()
      • setDays

        public void setDays​(int days)
      • getHours

        public int getHours()
      • setHours

        public void setHours​(int hours)
      • getMinutes

        public int getMinutes()
      • setMinutes

        public void setMinutes​(int minutes)
      • getSeconds

        public int getSeconds()
      • setSeconds

        public void setSeconds​(int seconds)
      • getMicroseconds

        public int getMicroseconds()
      • setMicroseconds

        public void setMicroseconds​(int microseconds)
      • hashCode

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

        public java.time.Duration toDuration()
        Convert this interval to an instance of Duration.

        The conversion algorithm assumes a year lasts 12 months and a month lasts 30 days, as Postgres does and ISO 8601 suggests.

        Returns:
        an instance of Duration representing the same amount of time as this interval