uom
Typed quantities and units of measurement for Java
A native API with typed products and a JSR-385 implementation, on one exact engine.
Exact conversions
Units convert exactly (rationals, powers of pi and roots). Values are double or exact BigDecimal.
Typed products
Length / Time is a Speed and Force ยท Length an Energy, wherever a relation between the types is declared.
JSR-385
uom-jsr implements unit-api 2.2 on the same engine and passes the TCK, 113 of 113 tests.
Length marathon = Length.of(42.195, SI.KILOMETRE);
Speed pace = marathon.divide(Time.of(3, SI.HOUR));
System.out.println(pace.to(USCustomary.MILE_PER_HOUR)); // prints: 8.739585818818103 mph
uom needs Java 17 or later and is on Maven Central. Its only third-party runtime
dependency is the JSR-385 unit-api, and only for uom-jsr.
<dependency>
<groupId>org.tinygears</groupId>
<artifactId>uom</artifactId>
<version>0.1.0</version>
</dependency>