unit conversion between mile and km using jsr 363 library

277 views Asked by At

Hi I am new to using jsr 363 to do a unit conversion application. Can anyone help me to do the conversion between mile and km using jsr 363 library(uni-api)

1

There are 1 answers

0
Werner Keil On BEST ANSWER

It's done like this:

Quantity<Length> len = Quantities.getQuantity(10, MetricPrefix.KILO(Units.METRE));
Quantity<Length> mile = len.to(USCustomary.MILE);

You'll find examples for using the Common systems (including USCustomary) under https://github.com/unitsofmeasurement/uom-demos/tree/master/console/systems/common

Cheers, Werner