unitsofmeasurement / indriya

JSR 385 - Reference Implementation
Other
119 stars 40 forks source link

Using Java 12 NumberFormat #251

Closed keilw closed 4 years ago

keilw commented 5 years ago

Based on #25 we may explore the possible use and impact of Java 12 NumberFormat enhancements like the COMPACT style.

Especially if numbers may contain characters in the format representation like "150.0K" or "15.0M" using this new option.

In a Java 12 specific version of certain classes, especially QuantityFormat implementations like NumberDelimiterQuantityFormat we should check if the NumberFormat used is a CompactNumberFormat.

See https://www.logicbig.com/tutorials/core-java-tutorial/java-12-changes/compact-number-format.html

Needs #25

filipvanlaenen commented 5 years ago

This Java 12 number format seems to be mostly directed towards human text and economical usages. I don't think this fits very well with e.g. the SI prefixes. We may risk that 1 GHz comes out as 1 BHz.

keilw commented 5 years ago

As the NumberDelimiterQuantityFormat allows any NumberFormat to be combined with UnitFormat, we might face that in any case. There locale specific aspects are also an option. That's why other locale-neutral formatters exist. There is a risk of either 1 BHz or worse like 1 GBHz, but for this particular QuantityFormat we can't prevent composition with that new NumberFormat type, which is why I suggested this to try cope with it where necessary.