|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucar.nc2.units.SimpleUnit
ucar.nc2.units.TimeUnit
public class TimeUnit
Handles Units that are time durations, eg in seconds, hours, days, years. It keeps track of the original unit name, rather than converting to canonical "seconds". The unit name never changes, but the value may.
This is a wrapper around ucar.units. The underlying ucar.units.Unit always has a value of "1.0", ie is a base unit.
Field Summary |
---|
Fields inherited from class ucar.nc2.units.SimpleUnit |
---|
dateReferenceUnit, debugParse, kmUnit, meterUnit, pressureUnit, secsUnit, uu |
Constructor Summary | |
---|---|
TimeUnit(double value,
String unitString)
Constructor from a value and a unit name. |
|
TimeUnit(String text)
Constructor from a String. |
|
TimeUnit(TimeUnit src)
Copy Constructor. |
Method Summary | |
---|---|
Date |
add(Date d)
Add the time amount to the given Date, return a new Date. |
double |
convertTo(double value,
TimeUnit outputUnit)
Convert given value of this unit to the new unit. |
boolean |
equals(Object o)
TimeUnits with same value and unitString are equal |
double |
getFactor()
Get the factor that converts this unit to seconds. |
String |
getUnitString()
Get the "base" unit String, eg "secs" or "days" |
double |
getValue()
Get the value. |
double |
getValueInSeconds()
Get the time duration in seconds. |
double |
getValueInSeconds(double value)
Get the time duration in seconds of the specified value. |
int |
hashCode()
Override hashcode to be consistent with equals. |
void |
setValue(double value)
Set the value in the original units. |
void |
setValueInSeconds(double secs)
Set the value, using the given number of seconds. |
String |
toString()
String representation. |
Methods inherited from class ucar.nc2.units.SimpleUnit |
---|
convertTo, factory, factoryWithExceptions, getCanonicalString, getConversionFactor, getImplementingClass, getUnit, isCompatible, isCompatible, isCompatibleWithExceptions, isDateUnit, isDateUnit, isTimeUnit, isTimeUnit, isUnknownUnit, makeUnit |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TimeUnit(String text) throws Exception
text
- [value] public TimeUnit(double value, String unitString) throws Exception
value
- amount of the unit.unitString
- Time unit string from udunits.
Exception
- if parse failspublic TimeUnit(TimeUnit src)
src
- copy from hereMethod Detail |
---|
public double getValue()
getValue
in class SimpleUnit
public double getFactor()
public void setValue(double value)
value
- set value, must be in units of thispublic String getUnitString()
getUnitString
in class SimpleUnit
public String toString()
toString
in class SimpleUnit
public double getValueInSeconds()
public double getValueInSeconds(double value)
value
- convert this value, must be in units of this
public void setValueInSeconds(double secs)
secs
- : number of seconds; convert this to the units of this TimeUnit.public double convertTo(double value, TimeUnit outputUnit) throws ConversionException
value
- in the units of this "base unit"outputUnit
- convert to this base type, must be convertible to units of "seconds"
ConversionException
public Date add(Date d)
d
- add to this Date
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |