Package gnu.math

Class Duration

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable

    public class Duration
    extends Quantity
    implements java.io.Externalizable
    See Also:
    Serialized Form
    • Field Detail

      • unit

        public Unit unit
    • Constructor Detail

      • Duration

        public Duration()
    • Method Detail

      • make

        public static Duration make​(int months,
                                    long seconds,
                                    int nanos,
                                    Unit unit)
      • makeMonths

        public static Duration makeMonths​(int months)
      • makeMinutes

        public static Duration makeMinutes​(int minutes)
      • parse

        public static Duration parse​(java.lang.String str,
                                     Unit unit)
      • parseDuration

        public static Duration parseDuration​(java.lang.String str)
      • parseYearMonthDuration

        public static Duration parseYearMonthDuration​(java.lang.String str)
      • parseDayTimeDuration

        public static Duration parseDayTimeDuration​(java.lang.String str)
      • valueOf

        public static Duration valueOf​(java.lang.String str,
                                       Unit unit)
        Parse a duration lexical value as specified by XML Schama. Return null if invalid syntax.
      • add

        public Numeric add​(java.lang.Object y,
                           int k)
        Description copied from class: Numeric
        Return this + k * obj.
        Overrides:
        add in class Quantity
      • compare

        public int compare​(java.lang.Object obj)
        Description copied from class: Numeric
        Return an integer for which of this or obj is larger. Return 1 if this>obj; 0 if this==obj; -1 if this<obj; -2 if this!=obj otherwise (for example if either is NaN); -3 if not comparable (incompatible types).
        Overrides:
        compare in class Quantity
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Numeric
      • getYears

        public int getYears()
        The number of years in the canonical representation.
      • getMonths

        public int getMonths()
      • getDays

        public int getDays()
      • getHours

        public int getHours()
      • getMinutes

        public int getMinutes()
      • getSecondsOnly

        public int getSecondsOnly()
      • getNanoSecondsOnly

        public int getNanoSecondsOnly()
      • getTotalMonths

        public int getTotalMonths()
      • getTotalSeconds

        public long getTotalSeconds()
      • getTotalMinutes

        public long getTotalMinutes()
      • getNanoSeconds

        public long getNanoSeconds()
      • isZero

        public boolean isZero()
        Specified by:
        isZero in class Numeric
      • isExact

        public boolean isExact()
        Specified by:
        isExact in class Numeric
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • hashCode

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

        public static boolean equals​(Duration x,
                                     Duration y)
        Compare for equality. Ignores unit.
      • equals

        public boolean equals​(java.lang.Object obj)
        Compare for equality. Ignores unit.
        Overrides:
        equals in class Numeric