@Immutable public class TimeDuration extends Object
| Constructor and Description |
|---|
TimeDuration(TimeUnit timeUnit)
Construct from a TimeUnit.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
String |
getText()
Get the text
|
TimeUnit |
getTimeUnit()
Get the time unit
|
double |
getValue()
Get the duration in natural units, ie units of getTimeUnit()
|
double |
getValue(String unit)
Get the time duration in a specified unit of time.
|
double |
getValue(TimeUnit want)
Get the time duration in a specified unit of time.
|
double |
getValueInSeconds()
Get the duration in seconds
|
int |
hashCode() |
boolean |
isBlank()
If this is a blank string
|
static TimeDuration |
parse(String text)
Construct from 1) udunit time unit string, 2) xsd:duration syntax, 3) blank string.
|
static TimeDuration |
parseW3CDuration(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.
|
String |
toString() |
public TimeDuration(TimeUnit timeUnit)
public static TimeDuration parse(String text) throws ParseException
text - parse this text.ParseException - if invalid text.public static TimeDuration parseW3CDuration(String text) throws ParseException
text - parse this text, format PnYnMnDTnHnMnSParseException - when text is misformedpublic double getValue()
public double getValue(TimeUnit want)
want - in these unitsIllegalArgumentException - if specified unit is not compatible with timepublic double getValue(String unit)
unit - unit spec from new TimeUnit(String)IllegalArgumentException - if specified unit is not compatible with timepublic double getValueInSeconds()
public boolean isBlank()
public TimeUnit getTimeUnit()
public String getText()