See: Description
Class | Description |
---|---|
AlternateUnit<Q extends javax.measure.Quantity<Q>> |
This class represents units used in expressions to distinguish between quantities of a different nature but of the same dimensions.
|
AnnotatedUnit<Q extends javax.measure.Quantity<Q>> |
This class represents an annotated unit.
|
BaseUnit<Q extends javax.measure.Quantity<Q>> |
This class represents the building blocks on top of which all others physical units are created.
|
ProductUnit<Q extends javax.measure.Quantity<Q>> |
This class represents units formed by the product of rational powers of existing physical units.
|
TransformedUnit<Q extends javax.measure.Quantity<Q>> |
This class represents the units derived from other units using converters.
|
Units |
This class defines commonly used units.
|
Enum | Description |
---|---|
MetricPrefix |
This class provides support for the 20 prefixes used in the metric system (decimal multiples and submultiples of units).
|
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 units.
import static tec.uom.se.unit.MetricPrefix.*;
import ...US.*; // US units (external module)
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]²
Copyright © 2005–2019 Units of Measurement project. All rights reserved.