Skip navigation links

Package ucar.units

Provides support for parsing and formatting string unit specification, converting numerical values between compatible units, and performing arithmetic on units (such as dividing one unit by another).

See: Description

Package ucar.units Description

Provides support for parsing and formatting string unit specification, converting numerical values between compatible units, and performing arithmetic on units (such as dividing one unit by another).

Examples of Intended Use

The following code will print the string "5 knots is 2.57222 m/s":
UnitFormat format = UnitFormatManager.instance();
Unit meter = format.parse("meter");
Unit second = format.parse("second");
Unit meterPerSecondUnit = meter.divideBy(second);
Unit knot = format.parse("knot");
if (meterPerSecondUnit.isCompatible(knot) {
    System.out.println("5 knots is " +
        knot.convertTo(5, meterPerSecondUnit) +
        ' ' + format.format(meterPerSecondUnit));
}
 
Skip navigation links