public class UnitsConverter extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
UnitsConverter.ConversionInfo |
static class |
UnitsConverter.Convertibility |
| Constructor and Description |
|---|
UnitsConverter(MeasureUnitImpl source,
MeasureUnitImpl target,
ConversionRates conversionRates)
Constructor of
UnitsConverter. |
UnitsConverter(String sourceIdentifier,
String targetIdentifier)
Constructor of
UnitsConverter. |
| Modifier and Type | Method and Description |
|---|---|
BigDecimal |
convert(BigDecimal inputValue) |
BigDecimal |
convertInverse(BigDecimal inputValue) |
static UnitsConverter.Convertibility |
extractConvertibility(MeasureUnitImpl source,
MeasureUnitImpl target,
ConversionRates conversionRates) |
UnitsConverter.ConversionInfo |
getConversionInfo() |
String |
toString() |
public UnitsConverter(String sourceIdentifier, String targetIdentifier)
UnitsConverter.
NOTE:
- source and target must be under the same category
- e.g. meter to mile --> both of them are length units.
NOTE:
This constructor creates an instance of UnitsConverter internally.
sourceIdentifier - represents the source unit identifier.targetIdentifier - represents the target unit identifier.public UnitsConverter(MeasureUnitImpl source, MeasureUnitImpl target, ConversionRates conversionRates)
UnitsConverter.
NOTE:
- source and target must be under the same category
- e.g. meter to mile --> both of them are length units.source - represents the source unit.target - represents the target unit.conversionRates - contains all the needed conversion rates.public static UnitsConverter.Convertibility extractConvertibility(MeasureUnitImpl source, MeasureUnitImpl target, ConversionRates conversionRates)
public BigDecimal convert(BigDecimal inputValue)
public BigDecimal convertInverse(BigDecimal inputValue)
public UnitsConverter.ConversionInfo getConversionInfo()