|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectucar.units.UnitImpl
ucar.units.TimeScaleUnit
public final class TimeScaleUnit
Provides support for a reference time unit whose origin is at a certain time. Instances of this class are immutable.
Nested Class Summary | |
---|---|
protected static class |
TimeScaleUnit.MyConverter
Provides support for Converter-s. |
Constructor Summary | |
---|---|
TimeScaleUnit(Unit unit,
Date origin)
Constructs from a reference unit and a time origin. |
|
TimeScaleUnit(Unit unit,
Date origin,
UnitName id)
Constructs from a reference unit, a time origin, and an identifier. |
Method Summary | |
---|---|
Unit |
clone(UnitName id)
Clones this unit, changing the identifier. |
boolean |
equals(Object object)
Indicates if this unit is semantically identical to an object. |
String |
getCanonicalString()
Returns the canonical string representation of the unit. |
Converter |
getConverterTo(Unit outputUnit)
Returns a Converter for converting numeric values from this unit to another unit. |
DerivedUnit |
getDerivedUnit()
Returns the derived unit underlying the reference time unit. |
Date |
getOrigin()
Returns the time origin. |
Unit |
getUnit()
Returns the reference unit. |
int |
hashCode()
Returns the hash code of this instance. |
boolean |
isCompatible(Unit that)
Indicates if numeric values in this unit are convertible to another unit. |
boolean |
isDimensionless()
Indicates if this unit is dimensionless. |
static void |
main(String[] args)
Tests this class. |
protected Unit |
myDivideBy(Unit that)
Divides this unit by another unit. |
protected Unit |
myDivideInto(Unit that)
Divides this unit into another unit. |
protected Unit |
myMultiplyBy(Unit that)
Multiplies this unit by another unit. |
protected Unit |
myRaiseTo(int power)
Raises this unit to a power. |
Unit |
shiftTo(Date origin)
Returns a unit identical to this instance but whose origin (i.e., zero value) has been shifted to the given time. |
Unit |
shiftTo(double origin)
Returns a unit identical to this instance but whose origin (i.e., zero value) has been shifted to the given value. |
String |
toString()
Returns the string representation of this unit. |
Methods inherited from class ucar.units.UnitImpl |
---|
convertTo, convertTo, convertTo, convertTo, convertTo, convertTo, divideBy, divideInto, getName, getPlural, getSymbol, getUnitName, log, makeLabel, multiplyBy, multiplyBy, raiseTo |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TimeScaleUnit(Unit unit, Date origin) throws BadUnitException, UnitSystemException
unit
- The reference time unit.origin
- The time origin.
BadUnitException
- unit
is not a unit of time.
UnitSystemException
public TimeScaleUnit(Unit unit, Date origin, UnitName id) throws BadUnitException, UnitSystemException
unit
- The reference time unit.origin
- The time origin.id
- The identifier.
BadUnitException
- unit
is not a unit of time.
UnitSystemException
Method Detail |
---|
public Unit getUnit()
public Date getOrigin()
public Unit clone(UnitName id)
id
- The new identifier.
public Unit shiftTo(double origin) throws ShiftException
Unit
degK
is a Kelvin unit, then degK.shiftTo(273.15)
is a Celsius unit.
shiftTo
in interface Unit
shiftTo
in class UnitImpl
origin
- The new origin in units of this instance.
origin
of this instance.
ShiftException
- if the corresponding new unit can't be created.public Unit shiftTo(Date origin) throws ShiftException
Unit
sec
is
a second unit, then sec.shiftTo(new Date(0L)
is the unit
corresponding to seconds since the epoch (1970-01-01 00:00:00 UTC).
shiftTo
in interface Unit
shiftTo
in class UnitImpl
origin
- The new origin.
origin
.
ShiftException
- if the corresponding new unit can't be created. For example,
if this instance isn't a unit of time.protected Unit myMultiplyBy(Unit that) throws MultiplyException
myMultiplyBy
in class UnitImpl
that
- The other unit.
MultiplyException
- Illegal operation. Always thrown.protected Unit myDivideBy(Unit that) throws DivideException
myDivideBy
in class UnitImpl
that
- The other unit.
DivideException
- Illegal operation. Always thrown.protected Unit myDivideInto(Unit that) throws DivideException
myDivideInto
in class UnitImpl
that
- The other unit.
DivideException
- Illegal operation. Always thrown.protected Unit myRaiseTo(int power) throws RaiseException
myRaiseTo
in class UnitImpl
power
- The power.
RaiseException
- Illegal operation. Always thrown.public DerivedUnit getDerivedUnit()
public Converter getConverterTo(Unit outputUnit) throws ConversionException
getConverterTo
in interface Unit
getConverterTo
in class UnitImpl
outputUnit
- The other unit. Shall be a TimeScaleUnit.
ConversionException
- outputUnit
is not a TimeScaleUnit.public final boolean isCompatible(Unit that)
isCompatible
in interface Unit
isCompatible
in class UnitImpl
that
- The other unit.
true
if and only if numeric values in this unit are
convertible to
that
.public boolean equals(Object object)
equals
in interface Unit
equals
in class Object
object
- The object.
true
if and only if this unit is semantically
identical to object
.public int hashCode()
hashCode
in class UnitImpl
public boolean isDimensionless()
false
.public String toString()
toString
in interface Unit
toString
in class UnitImpl
public String getCanonicalString()
public static void main(String[] args) throws Exception
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |