indriya
indriya copied to clipboard
JSR 385 - Reference Implementation
Trying to use `EBNFUnitFormat` as a way to serialize and de-serialize unit information into a database, I found that it can produce output that it cannot parse back anymore. Example...
``` SimpleUnitFormat.getInstance().alias(USCustomary.MILE, "mile"); Quantity q1 = ServiceProvider.current().getFormatService().getQuantityFormat().parse("3 km"); Quantity q2 = ServiceProvider.current().getFormatService().getQuantityFormat().parse("3 mi"); Quantity q3 = ServiceProvider.current().getFormatService().getQuantityFormat().parse("3 mile"); // Quantity q4 = ServiceProvider.current().getFormatService().getQuantityFormat().parse("3 1/km"); // Exception Quantity q5 = ServiceProvider.current().getFormatService().getQuantityFormat("EBNF").parse("3...
My target is to create "custom" units for electricity prices: €/MWh and c/kWh. I added following classes: ```java public class CurrencyDimension implements Dimension, Serializable { // Copied from BaseUnit because...
Adding a "pattern" similar to `SimpleQuantityFormat` or `SimpleDateFormat` to `SimpleUnitFormat`, so the formatting and parsing could be finer-controlled to use e.g. the name, symbol or label/identifier of a unit.
In https://github.com/openhab/openhab-core/issues/3962 we found that `d` works as unit for days, but `y` does not work for years. The same applied to `mo` and `wk`. I believe the difference is...
`EBNFUnitFormat` and `LocalUnitFormat` are both based on resource bundles and SymbolMap. It could help to harmonize some of them with an abstract common base class like `SymbolMapUnitFormat` or similar. Also...
Right now the internals of `SimpleUnitFormat` contain the notion of `nameToUnit` and `unitToName`, but they are not really names, because only **label** or `alias` are used at the moment. Along...
Looking at a GeoTools benchmark lately I've found this stack trace reducing scalability, to the point that the application (map rendering) can only use 80% of CPU. Here is the...
Turn `QuantityRange` into a `record `for Java 17+
``` val formatter = DefaultFormatService().getUnitFormat("EBNF") val test = Units.METRE.multiply(2).multiply(2) println(formatter.format(test)) ``` result: m·2 I guess the reason for that is that EBNFHelper.formatInternal is using "parentUnit = unit.getSystemUnit()" instead of the...