2

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)

Hariprasath
  • 539
  • 1
  • 9
  • 21

1 Answers1

1

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

Werner Keil
  • 592
  • 5
  • 12