public class Length extends java.lang.Object implements QuantityUnitMeasure<DistanceUnit>
| Constructor and Description |
|---|
Length(float length)
Create a Length with the specified magnitude in meters.
|
Length(float length,
DistanceUnit unit)
Create a Length with the specified magnitude.
|
Length(java.lang.String value)
Decode a Length value from the specified String representation.
|
| Modifier and Type | Method and Description |
|---|---|
float |
getMagnitude()
Get the magnitude of this length in its unit.
|
float |
getMagnitude(DistanceUnit otherUnit)
Get this length in the specified units.
|
float |
getMagnitudeInDefaultUnit()
Get the length in the application-default units (meters).
|
DistanceUnit |
getUnit()
Get the unit in which the length magnitude is measured.
|
java.lang.String |
toString()
Returns a string representation of the object.
|
public Length(java.lang.String value)
value - a String representation of a lengthjava.lang.IllegalArgumentException - if the string cannot be successfully parsedpublic Length(float length,
DistanceUnit unit)
length - float length value in the specified unitsunit - DistanceUnit of the length valuepublic Length(float length)
length - float length value in meterspublic float getMagnitude()
getMagnitude in interface QuantityUnitMeasure<DistanceUnit>public float getMagnitude(DistanceUnit otherUnit)
getMagnitude in interface QuantityUnitMeasure<DistanceUnit>otherUnit - DistanceUnit for scaling the lengthpublic float getMagnitudeInDefaultUnit()
getMagnitudeInDefaultUnit in interface QuantityUnitMeasure<DistanceUnit>public DistanceUnit getUnit()
getUnit in interface QuantityUnitMeasure<DistanceUnit>public java.lang.String toString()
toString in class java.lang.Object