public class TimeUnit extends SimpleUnit
This is a wrapper around ucar.units. The underlying ucar.units.Unit always has a value of "1.0", ie is a base unit. TODO: 8/12/2020 make Immutable in version 7
dateReferenceUnit, debugParse, kmUnit, meterUnit, pressureUnit, secsUnit, uu| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
CalendarDate |
add(CalendarDate cd)
Add the time amount to the given Date, return a new Date.
|
Date |
add(Date d)
Deprecated.
use add(CalendarDate)
|
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.
|
TimeUnit |
newValue(double value)
Create a new TimeUnit with the given value.
|
TimeUnit |
newValueInSeconds(double secs)
Create a new TimeUnit with the given value in seconds.
|
void |
setValue(double value)
Deprecated.
use newValue(double)
|
void |
setValueInSeconds(double secs)
Deprecated.
use newValueInSeconds(double)
|
String |
toString()
String representation.
|
convertTo, factory, factoryWithExceptions, getCanonicalString, getConversionFactor, getImplementingClass, getUnit, isCompatible, isCompatible, isCompatibleWithExceptions, isDateUnit, isDateUnit, isTimeUnit, isTimeUnit, isUnknownUnit, makeUnitpublic TimeUnit(String text) throws ucar.units.UnitException
text - [value] ucar.units.UnitException - if bad formatpublic TimeUnit(double value,
String unitString)
throws ucar.units.UnitException
value - amount of the unit.unitString - Time unit string from udunits.ucar.units.UnitException - if parse failspublic TimeUnit(TimeUnit src)
src - copy from herepublic double getValue()
getValue in class SimpleUnitpublic double getFactor()
@Deprecated public void setValue(double value)
value - set value, must be in units of thispublic TimeUnit newValue(double value)
public String getUnitString()
getUnitString in class SimpleUnitpublic String toString()
toString in class SimpleUnitpublic double getValueInSeconds()
public double getValueInSeconds(double value)
value - convert this value, must be in units of this@Deprecated public void setValueInSeconds(double secs)
secs - : number of seconds; convert this to the units of this TimeUnit.public TimeUnit newValueInSeconds(double secs)
public double convertTo(double value,
TimeUnit outputUnit)
throws ucar.units.ConversionException
value - in the units of this "base unit"outputUnit - convert to this base type, must be convertible to units of "seconds"ucar.units.ConversionException@Deprecated public Date add(Date d)
d - add to this Datepublic CalendarDate add(CalendarDate cd)
cd - add to this CalendarDatepublic boolean equals(Object o)