8

JSR-275 has been rejected, the Units of Measurement API for Java project is a set of interfaces, but haven't found an open source implementation.

On this post: Which jsr-275 units implementation should be used? the project owner mentions the implementation was going to be ready by the end of last year on JScience, but didn't find anything there to convert between weight or length units and when I looked for JScience on https://maven.java.net/, I found it, but the JAR wasn't even in the directory https://maven.java.net/content/repositories/snapshots/org/jscience/jscience/5.0-SNAPSHOT/, so I had to get it from somewhere else.

Has this project been left behind? And is there currently an implementation for conversion of Units of measurement in Java and even perhaps a Maven repo?

Community
  • 1
  • 1
CCC
  • 2,642
  • 7
  • 40
  • 62

3 Answers3

6

Unit-API (unitsofmeasurement.org) is the successor to JSR-275.

The most active implementation at the moment is Eclipse UOMo

Werner Keil
  • 592
  • 5
  • 12
  • I know that I'm almost 2 years late to the party at this point but; is there any way to use UOMo from a static jar file? Or do you have to use the Eclipse plugin framework as the tutorial shows? It looks perfect for our use, but I'm having a real hard time of integrating this into our current project. I also have a question posted about it here:http://stackoverflow.com/questions/26870068/how-to-use-eclipse-uomo-units-of-measurement-in-standalone-project – Andy Nov 12 '14 at 15:39
  • 1
    Andy, Thanks for your interest. Given a "new party" just started last April with JSR 363 approved and looking at bigger support thanks to a general IoT trend, you might want to check out JSR 363 and related projects on http://unitsofmeasurement.github.io/ – Werner Keil Jan 21 '15 at 18:19
  • 1
    Link is now broken. I think the replacement site is https://unitsofmeasurement.github.io/ – James Mudd Jun 10 '21 at 15:11
  • Yes you're correct, this was originally from 2013, about a year later even before unitsofmeasurement.org was discontinued JSR 363 and with it unitsofmeasurement.github.io (or aliases like uom.technology) became available as the new home to the project. – Werner Keil Jun 11 '21 at 16:05
3

As far as I know, JScience is very much alive. The project is currently being migrated to Java.net, and the migration is not complete. That is most likely the reason why you are unable to see snapshot JARs for 5.0. In fact, the most recent snapshot was prepared only after resolution of a particular configuration problem reported in the Java.net JIRA. May be you ought to wait a few days, or probably send a mail to the project administrator on what JScience POM must be used in the interim.

Vineet Reynolds
  • 76,006
  • 17
  • 150
  • 174
0

Update on this JSR-363 Units of Measurement API was completed in 2016 and provides a fairly complete UoM API. This has now been superseded by JSR-385 Units of Measurement API 2.0. You can find the code behind the API and implementation on Github here https://github.com/unitsofmeasurement.

Here is a simple conversion example using UoM API 2.0

import tech.units.indriya.quantity.Quantities;
import javax.measure.Quantity;
import javax.measure.quantity.Length;

import static javax.measure.MetricPrefix.CENTI;
import static tech.units.indriya.unit.Units.METRE;

class SimpleUnitExample {
    public static void main(String[] args) {
        Quantity<Length> lengthQuantity = Quantities.getQuantity(25, METRE);
        System.out.println(lengthQuantity.to(CENTI(METRE)));
    }
}

With a dependency on tech.units:indriya:2.0.4 will print 2500 cm.

You can find lots more examples in this repo uom-demos.

James Mudd
  • 1,816
  • 1
  • 20
  • 25