Skip navigation links

Package tec.uom.se

This package provides a Java SE 8 implementation of the Units of Measurement API.

See: Description

Package tec.uom.se Description

This package provides a Java SE 8 implementation of the Units of Measurement API.

Usage:

import javax.measure.quantity.*; // Holds quantity types. import tec.uom.se.AbstractUnit; import tec.uom.se.function.AbstractConverter; import static tec.uom.se.unit.Units.*; // Standard CommonUnits. import static tec.uom.se.unit.MetricPrefix.*; import static tec.uom.se.spi.UCUM.*; // Standard & Non-Standard CommonUnits. public class Main { public void main(String[] args) { // Conversion between units (explicit way). AbstractUnit sourceUnit = KILO(METRE); AbstractUnit targetUnit = MILE; PhysicsConverter uc = sourceUnit.getConverterTo(targetUnit); System.out.println(uc.convert(10)); // Converts 10 km to miles. // Same conversion than above, packed in one line. System.out.println(KILO(METRE).getConverterTo(MILE).convert(10)); // Retrieval of the SI unit (identifies the measurement type). System.out.println(REVOLUTION.divide(MINUTE).toSI()); // Dimension checking (allows/disallows conversions) System.out.println(ELECTRON_VOLT.isCompatible(WATT.times(HOUR))); // Retrieval of the unit dimension (depends upon the current model). System.out.println(ELECTRON_VOLT.getDimension()); } } > 6.2137119223733395 > 6.2137119223733395 > rad/s > true > [L]²·[M]/[T]²

Unit Parameterization

CommonUnits are parameterized enforce compile-time checks of units/measures consistency, for example:[code] AbstractUnit
Version:
0.2
Skip navigation links