public class Weight extends java.lang.Object implements QuantityUnitMeasure<WeightUnit>
Constructor and Description |
---|
Weight(float weight)
Create a Weight in short tons.
|
Weight(float weight,
WeightUnit unit)
Create a Weight of the specified magnitude and units.
|
Weight(java.lang.String value)
Create a Weight from a String encoding, which may include a weight unit name.
|
Modifier and Type | Method and Description |
---|---|
float |
getMagnitude()
Get the magnitude of this value in its unit.
|
float |
getMagnitude(WeightUnit otherUnit)
Get this length in the specified units.
|
float |
getMagnitudeInDefaultUnit()
Get the magnitude of this value in the default unit for the value class,
scaling it if stored in a different unit.
|
WeightUnit |
getUnit()
Get the unit in which the magnitude is measured.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
public Weight(java.lang.String value) throws java.lang.IllegalArgumentException
value
- String value to decodejava.lang.IllegalArgumentException
- if weight cannot be decodedpublic Weight(float weight, WeightUnit unit)
weight
- magnitude of weightunit
- WeightUnit of the valuepublic Weight(float weight)
weight
- quantity of tons in the weightpublic float getMagnitude()
getMagnitude
in interface QuantityUnitMeasure<WeightUnit>
public float getMagnitude(WeightUnit otherUnit)
getMagnitude
in interface QuantityUnitMeasure<WeightUnit>
otherUnit
- UnitEnum
for scaling the valuepublic float getMagnitudeInDefaultUnit()
getMagnitudeInDefaultUnit
in interface QuantityUnitMeasure<WeightUnit>
public WeightUnit getUnit()
getUnit
in interface QuantityUnitMeasure<WeightUnit>
UnitEnum
of the unitpublic java.lang.String toString()
toString
in class java.lang.Object