unitsofmeasurement/uom-systems

Using c/s on systems/ucum 2.0-SNAPSHOT.

TD-3294 opened this issue · 6 comments

Hello,
I have been using version 1.0 up until today, when I decided to move to 2.0-SNAPSHOT. It all works, except that a lot of data has been created using UCUM v.1. formatter/parser which gave me the c/s representation of units. For example, degrees Farenheit is represented as [degF]. With version 2.0-SNAPSHOT, how can I get the same parsing/formatting?
I see that the format is at UCUMFormat_CS.properties, but I cannot find out how to use it.
Thanks,
Juan

OK - this is my Github user...

keilw commented

@jfarjona I think this belongs here, because referring to e.g. a UCUM properties file. Have to analyze it, could you provide a code snippet how you used V1 or try to use V2?

Thanks!
I fixed it last night. I had:

FormatService formatService = provider.getFormatService();
UnitFormat ucumFormat = formatService.getUnitFormat("Local");

and now I have (hack from the test code):

UCUMFormat fmt = UCUMFormat.getInstance(UCUMFormat.Variant.CASE_SENSITIVE);
ucumFormat = fmt;

and it works as it did before.

It would be nice to have a method with the variant option, something like:

getUnitFormat(String name, String variant)

Unless is there and I just missed it.

Thanks a lot.

Juan

...and in V1, I had:

 UnitFormatService formatService = provider.getUnitFormatService();
 ucumFormat        = formatService.getUnitFormat("UCUM");
keilw commented

Overriding or setting the current() provider has changed a little, but for UCUM I believe that's also done in V2, otherwise ServiceProvider.of("UCUM") or similar should be used now instead of ServiceProvider.current() because the current one may not be overriden any more. The problem is, the "variant" is very UCUM specific, but if we either keep that or find a slightly different name (think of how to retrieve a Locale) I'd say this is a viable option for an improvement in a future version. As this would be an API change, could you file it under https://github.com/unitsofmeasurement/unit-api/issues please? It may be small enough for a MR if it only adds a new argument, but It would need a MR at least for that.