|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucar.nc2.units.TimeDuration
public class TimeDuration
Implements the thredds "duration" XML element type: specifies a length of time. This is really the same as a ucar.nc2.units.TimeUnit, but it allows xsd:duration syntax as well as udunits syntax. It also keeps track if the text is empty.
A duration can be one of the following:
Constructor Summary | |
---|---|
TimeDuration(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. |
Method Summary | |
---|---|
boolean |
equals(Object o)
TimeDurations with same value in seconds are equals |
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(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 void |
main(String[] args)
|
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. |
void |
setValueInSeconds(double secs)
Set the duration in seconds |
String |
toString()
String representation |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TimeDuration(TimeDuration src)
src
- copy thispublic TimeDuration(TimeUnit timeUnit)
timeUnit
- copy thispublic TimeDuration(String text) throws ParseException
text
- parse this text.
ParseException
- if invalid text.Method Detail |
---|
public static TimeDuration parseW3CDuration(String text) throws ParseException
text
- parse this text, format PnYnMnDTnHnMnS
ParseException
- when text is misformedpublic double getValue()
public double getValue(TimeUnit want) throws ConversionException
want
- in these units
ConversionException
- is specified unit is not compatible with timepublic double getValueInSeconds()
public void setValueInSeconds(double secs)
secs
- the duration in secondspublic boolean isBlank()
public TimeUnit getTimeUnit()
public String getText()
public String toString()
toString
in class Object
public int hashCode()
hashCode
in class Object
public boolean equals(Object o)
equals
in class Object
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |