Closed mattdehring closed 4 years ago
I made a PR that has unit tests for the problems and a solution for it
I just run into the same problem. Thanks for the fix.
Unfortunately you introduced a new bug with commit 2fdd93da6c. kg/m2
formats to kg/m
now. The fix is simple, you just have an Math.abs
too much. You can find it here:
That does not seem new with 1.0 though which only incorporates SI 1.0, could you propose a line instead of if (Math.abs(u.getValue()) < -1){
that fixes the issue in your experience or propose a PR?
I am not sure about this process who should make the fix? It should just be changed to if ( u.getValue() < -1){
. This needs to be done for both versions.
Thanks @keilw @mattdehring I decided agains a PR because I don't oversee all locations it has to be fixed.
So without the abs()
, we'll try that. Because the SI redefinition affects the SI system modules and probably in some cases also UCUM directly, we expect one or the other update in the 1.x branch independent of the 2.x (master) branch.
Would you recommend to use the 2.x branch instead? I remember having some problems using the whole 2.x system. But not exactly how. I only need to parse and format unit and quantities for calculation.
2.0 of Unit-API is not final yet, but if you are fine with a SNAPSHOT release, it works and will be the one taking over soon.
Ok thanks. Now I understand. No, I can't use a SNAPSHOT.
Great, than please use 1.x at least till around late Q2, then all 2.x versions based on Indriya 2 Final and JSR 385 should be available. And if you used uom-se or the -java8 variants, those work on identical environments. The minimal JRE should be Java SE 8 in most cases, on occasion we might raise it to 9-11, especially if new features are used like JShell or the var
keyword.
Thank you a lot. I use 1.x in -java8 variant with Java SE 8 but might be update to Java SE 11 later this year.
Hello, is there any news about this issue? I am using version 2.0 (not snapshot) and
UCUMFormat.getInstance(UCUMFormat.Variant.CASE_SENSITIVE).format(UCUM.GRAM.divide(UCUM.METER.pow(3)))
produces g/m
instead of g/m3
.
As demonstrated in UCUMFormatDemo
of the UCUM console demos, this was fixed by #162 in 2.0.2, please test the SNAPSHOT, we plan to release it soon.
If a unit like m3/s is input the output is m/s3 instead. It also appears that if there are multiple units in the denominator it doesn't correctly add parenthesis around them. For instance if you have an input of m/(s.bar) the output is m/s/b.