Package gnu.math
Class Duration
- java.lang.Object
-
- java.lang.Number
-
- gnu.math.Numeric
-
- gnu.math.Quantity
-
- gnu.math.Duration
-
- All Implemented Interfaces:
Externalizable
,Serializable
public class Duration extends Quantity implements Externalizable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Duration()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Duration
add(Duration x, Duration y, int k)
Numeric
add(Object y, int k)
Return this + k * obj.static int
compare(Duration x, Duration y)
int
compare(Object obj)
Return an integer for which ofthis
orobj
is larger.static double
div(Duration dur1, Duration dur2)
Numeric
div(Object y)
static boolean
equals(Duration x, Duration y)
Compare for equality.boolean
equals(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(Object y)
Numeric
mulReversed(Numeric x)
Complex
number()
static Duration
parse(String str, Unit unit)
static Duration
parseDayTimeDuration(String str)
static Duration
parseDuration(String str)
static Duration
parseYearMonthDuration(String str)
void
readExternal(ObjectInput in)
static Duration
times(Duration x, double y)
String
toString()
Unit
unit()
static Duration
valueOf(String str, Unit unit)
Parse a duration lexical value as specified by XML Schama.void
writeExternal(ObjectOutput out)
-
Methods inherited from class gnu.math.Quantity
abs, add, addReversed, compare, compareReversed, dimensions, divide, divReversed, doubleImagValue, doubleJmagValue, doubleKmagValue, doubleValue, im, imValue, jm, jmValue, km, kmValue, make, make, make, neg, re, reValue, times, toString
-
Methods inherited from class gnu.math.Numeric
add, asNumericOrNull, div_inv, floatValue, geq, grt, intValue, longValue, mul_ident, power, sub, toExact, toInexact
-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Field Detail
-
unit
public Unit unit
-
-
Method Detail
-
makeMonths
public static Duration makeMonths(int months)
-
makeMinutes
public static Duration makeMinutes(int minutes)
-
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.
-
mulReversed
public Numeric mulReversed(Numeric x)
- Overrides:
mulReversed
in classQuantity
-
compare
public int compare(Object obj)
Description copied from class:Numeric
Return an integer for which ofthis
orobj
is larger. Return 1 ifthis>obj
; 0 ifthis==obj
; -1 ifthis<obj
; -2 ifthis!=obj
otherwise (for example if either is NaN); -3 if not comparable (incompatible types).
-
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()
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
-