public class SimpleUnit
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static Unit |
dateReferenceUnit |
protected static boolean |
debugParse |
static SimpleUnit |
kmUnit |
static SimpleUnit |
meterUnit |
static SimpleUnit |
pressureUnit |
protected static Unit |
secsUnit |
protected Unit |
uu |
Modifier | Constructor and Description |
---|---|
protected |
SimpleUnit()
for subclasses.
|
Modifier and Type | Method and Description |
---|---|
double |
convertTo(double value,
SimpleUnit outputUnit)
Convert given value of this unit to the new unit.
|
static SimpleUnit |
factory(java.lang.String name)
Create a SimpleUnit from the given name, catch Exceptions.
|
static SimpleUnit |
factoryWithExceptions(java.lang.String name)
Create a SimpleUnit from the given name, allow Exceptions.
|
java.lang.String |
getCanonicalString() |
static double |
getConversionFactor(java.lang.String inputUnitString,
java.lang.String outputUnitString)
Get the conversion factor to convert inputUnit to outputUnit.
|
java.lang.String |
getImplementingClass() |
Unit |
getUnit()
Get underlying ucar.units.Unit.
|
java.lang.String |
getUnitString()
Extract the simple unit string (no number), eg "s" or "m".
|
double |
getValue()
Extract the value, can only be called for ScaledUnit.
|
boolean |
isCompatible(java.lang.String unitString)
Return true if unitString1 is compatible to unitString2,
meaning one can be converted to the other.
|
static boolean |
isCompatible(java.lang.String unitString1,
java.lang.String unitString2)
Return true if unitString1 is compatible to unitString2, meaning one can be converted to the other.
|
static boolean |
isCompatibleWithExceptions(java.lang.String unitString1,
java.lang.String unitString2)
Return true if unitString1 is convertible to unitString2
|
static boolean |
isDateUnit(java.lang.String unitString)
Return true if the given unit is convertible to a date Unit.
|
static boolean |
isDateUnit(Unit uu)
Return true if this ucar.units.Unit is a Date.
|
static boolean |
isTimeUnit(java.lang.String unitString)
Return true if the given unit is a time Unit, eg "seconds".
|
static boolean |
isTimeUnit(Unit uu)
Return true if this ucar.units.Unit is convertible to secs.
|
boolean |
isUnknownUnit()
Is this an instance of an UnknownUnit?
|
protected static Unit |
makeUnit(java.lang.String name) |
java.lang.String |
toString()
Unit string representation.
|
public static final SimpleUnit kmUnit
public static final SimpleUnit meterUnit
public static final SimpleUnit pressureUnit
protected static Unit secsUnit
protected static Unit dateReferenceUnit
protected static boolean debugParse
protected Unit uu
public static SimpleUnit factory(java.lang.String name)
name
- parse this name to create a unit.UnitFormat.parse(java.lang.String)
public static SimpleUnit factoryWithExceptions(java.lang.String name) throws java.lang.Exception
name
- parse this name to create a unit.java.lang.Exception
- when date parser failsUnitFormat.parse(java.lang.String)
protected static Unit makeUnit(java.lang.String name) throws java.lang.Exception
java.lang.Exception
public static boolean isCompatible(java.lang.String unitString1, java.lang.String unitString2)
unitString1
- compare this unitunitString2
- compare this unitpublic static boolean isCompatibleWithExceptions(java.lang.String unitString1, java.lang.String unitString2) throws java.lang.Exception
unitString1
- compare this unitunitString2
- compare this unitjava.lang.Exception
- if units parsing failspublic static boolean isDateUnit(Unit uu)
uu
- check this Unitpublic static boolean isTimeUnit(Unit uu)
uu
- check this Unitpublic static boolean isDateUnit(java.lang.String unitString)
[-]Y[Y[Y[Y]]]-MM-DD[(T| )hh[:mm[:ss[.sss*]]][ [+|-]hh[[:]mm]]]
unitString
- check this unit stringpublic static boolean isTimeUnit(java.lang.String unitString)
unitString
- check this unit stringpublic static double getConversionFactor(java.lang.String inputUnitString, java.lang.String outputUnitString) throws java.lang.IllegalArgumentException
inputUnitString
- inputUnit in string formoutputUnitString
- outputUnit in string formjava.lang.IllegalArgumentException
- if not convertiblepublic java.lang.String toString()
toString
in class java.lang.Object
public Unit getUnit()
public double convertTo(double value, SimpleUnit outputUnit) throws java.lang.IllegalArgumentException
value
- value in this unitoutputUnit
- convert to this unitjava.lang.IllegalArgumentException
- if outputUnit not convertible from this unitpublic boolean isCompatible(java.lang.String unitString)
unitString
- check if this is compatible with unitStringpublic boolean isUnknownUnit()
public double getValue()
public java.lang.String getUnitString()
public java.lang.String getCanonicalString()
public java.lang.String getImplementingClass()