public class TimeDuration
extends java.lang.Object
Constructor and Description |
---|
TimeDuration(java.lang.String text)
Construct from 1) udunit time unit string, 2) xsd:duration syntax, 3) blank string.
|
TimeDuration(TimeDuration src)
Copy constructor.
|
TimeDuration(TimeUnit timeUnit)
Construct from a TimeUnit.
|
Modifier and Type | Method and Description |
---|---|
java.util.Date |
add(java.util.Date d) |
boolean |
equals(java.lang.Object o)
TimeDurations with same value in seconds are equals
|
java.lang.String |
getText()
Get the String text
|
TimeUnit |
getTimeUnit()
Get the corresponding time unit
|
double |
getValue()
Get the duration in natural units, ie units of getTimeUnit()
|
double |
getValue(java.lang.String unit) |
double |
getValue(TimeUnit want)
Get the time duration in a specified unit of time.
|
double |
getValueInSeconds()
Get the duration in seconds
|
int |
hashCode()
Override to be consistent with equals
|
boolean |
isBlank()
If this is a blank string
|
static TimeDuration |
parseW3CDuration(java.lang.String text)
A time span as defined in the W3C XML Schema 1.0 specification:
"PnYnMnDTnHnMnS, where nY represents the number of years, nM the number of months, nD the number of days,
'T' is the date/time separator, nH the number of hours, nM the number of minutes and nS the number of seconds.
|
void |
setValueInSeconds(double secs)
Set the duration in seconds
|
java.lang.String |
toString()
String representation
|
public TimeDuration(java.lang.String text) throws java.text.ParseException
text
- parse this text.java.text.ParseException
- if invalid text.public TimeDuration(TimeDuration src)
src
- copy thispublic TimeDuration(TimeUnit timeUnit)
timeUnit
- copy thispublic java.util.Date add(java.util.Date d)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String getText()
public TimeUnit getTimeUnit()
public double getValue()
public double getValue(java.lang.String unit)
public double getValue(TimeUnit want) throws ucar.units.ConversionException
want
- in these unitsucar.units.ConversionException
- is specified unit is not compatible with timepublic double getValueInSeconds()
public int hashCode()
hashCode
in class java.lang.Object
public boolean isBlank()
public static TimeDuration parseW3CDuration(java.lang.String text) throws java.text.ParseException
text
- parse this text, format PnYnMnDTnHnMnSjava.text.ParseException
- when text is misformedpublic void setValueInSeconds(double secs)
secs
- the duration in secondspublic java.lang.String toString()
toString
in class java.lang.Object