Package gnu.math

Class Duration

All Implemented Interfaces:
Externalizable, Serializable

public class Duration extends Quantity implements Externalizable
See Also:
  • Field Details

    • unit

      public Unit unit
  • Constructor Details

    • Duration

      public Duration()
  • Method Details

    • 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(String str, Unit unit)
    • parseDuration

      public static Duration parseDuration(String str)
    • parseYearMonthDuration

      public static Duration parseYearMonthDuration(String str)
    • parseDayTimeDuration

      public static Duration parseDayTimeDuration(String str)
    • valueOf

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

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

      public Numeric mul(Object y)
      Overrides:
      mul in class Quantity
    • mulReversed

      public Numeric mulReversed(Numeric x)
      Overrides:
      mulReversed in class Quantity
    • div

      public static double div(Duration dur1, Duration dur2)
    • div

      public Numeric div(Object y)
      Overrides:
      div in class Quantity
    • add

      public static Duration add(Duration x, Duration y, int k)
    • times

      public static Duration times(Duration x, double y)
    • compare

      public static int compare(Duration x, Duration y)
    • compare

      public int compare(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 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(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException
    • unit

      public Unit unit()
      Overrides:
      unit in class Quantity
    • number

      public Complex number()
      Specified by:
      number in class Quantity
    • hashCode

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

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

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