public final class Quantities extends Object
Quantity
instances.Modifier and Type | Method and Description |
---|---|
static javax.measure.Quantity<?> |
getQuantity(CharSequence csq)
Returns the
numeric quantity of unknown type corresponding to the specified representation. |
static <Q extends javax.measure.Quantity<Q>> |
getQuantity(Number value,
javax.measure.Unit<Q> unit)
Returns the scalar measurement in the specified unit.
|
public static javax.measure.Quantity<?> getQuantity(CharSequence csq)
numeric
quantity of unknown type corresponding to the specified representation. This method
can be used to parse dimensionless quantities.
Quantity<Dimensionless> proportion = NumberQuantity.of("0.234").asType(Dimensionless.class);
Note: This method handles only standard
unit format (UCUM based). Locale-sensitive measure formatting and parsing are handled by the QuantityFormat
class and its subclasses.
csq
- the decimal value and its unit (if any) separated by space(s).QuantityFormat.getInstance(LOCALE_NEUTRAL).parse(csq)
public static <Q extends javax.measure.Quantity<Q>> javax.measure.Quantity<Q> getQuantity(Number value, javax.measure.Unit<Q> unit)
value
- the measurement value.unit
- the measurement unit.numeric
quantity.NullPointerException
- when value or unit were nullCopyright © 2005–2017 Jean-Marie Dautelle, Werner Keil, V2COM. All rights reserved.