gnu.math
Class Duration
java.lang.Object
java.lang.Number
gnu.math.Numeric
gnu.math.Quantity
gnu.math.Duration
- All Implemented Interfaces:
- java.io.Externalizable, java.io.Serializable
public class Duration
- extends Quantity
- implements java.io.Externalizable
- See Also:
- Serialized Form
Method Summary |
static Duration |
add(Duration x,
Duration y,
int k)
|
Numeric |
add(java.lang.Object y,
int k)
Return this + k * obj. |
static int |
compare(Duration x,
Duration y)
|
int |
compare(java.lang.Object obj)
Return an integer for which of {# code this} or {#code obj} is larger. |
static double |
div(Duration dur1,
Duration dur2)
|
Numeric |
div(java.lang.Object y)
|
static boolean |
equals(Duration x,
Duration y)
Compare for equality. |
boolean |
equals(java.lang.Object obj)
Compare for equality. |
int |
getDays()
|
int |
getHours()
|
int |
getMinutes()
|
int |
getMonths()
|
long |
getNanoSeconds()
|
int |
getNanoSecondsOnly()
|
int |
getSecondsOnly()
|
long |
getTotalMinutes()
|
int |
getTotalMonths()
|
long |
getTotalSeconds()
|
int |
getYears()
The number of years in the canonical representation. |
int |
hashCode()
|
boolean |
isExact()
|
boolean |
isZero()
|
static Duration |
make(int months,
long seconds,
int nanos,
Unit unit)
|
static Duration |
makeMinutes(int minutes)
|
static Duration |
makeMonths(int months)
|
Numeric |
mul(java.lang.Object y)
|
Numeric |
mulReversed(Numeric x)
|
Complex |
number()
|
static Duration |
parse(java.lang.String str,
Unit unit)
|
static Duration |
parseDayTimeDuration(java.lang.String str)
|
static Duration |
parseDuration(java.lang.String str)
|
static Duration |
parseYearMonthDuration(java.lang.String str)
|
void |
readExternal(java.io.ObjectInput in)
|
static Duration |
times(Duration x,
double y)
|
java.lang.String |
toString()
|
Unit |
unit()
|
static Duration |
valueOf(java.lang.String str,
Unit unit)
Parse a duration lexical value as specified by XML Schama. |
void |
writeExternal(java.io.ObjectOutput out)
|
Methods inherited from class gnu.math.Quantity |
abs, add, addReversed, compare, compareReversed, dimensions, divide, divReversed, doubleImagValue, doubleValue, im, imValue, make, make, make, neg, re, reValue, times, toString |
Methods inherited from class java.lang.Number |
byteValue, shortValue |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
unit
public Unit unit
Duration
public Duration()
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
mul
public Numeric mul(java.lang.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(java.lang.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(java.lang.Object obj)
- Description copied from class:
Numeric
- Return an integer for which of {# code this} or {#code 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
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 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