Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleUnitFormat.parse() does not always work with prefixes #343

Open
keilw opened this issue Apr 17, 2021 · 1 comment
Open

SimpleUnitFormat.parse() does not always work with prefixes #343

keilw opened this issue Apr 17, 2021 · 1 comment

Comments

@keilw
Copy link
Member

keilw commented Apr 17, 2021

There are at least one or two cases where SimpleUnitFormat.parse() (or AbstractUnit.parse()) won't recognize a string that can be properly formatted, it seems related to prefixes where observed.

E.g. AbstractUnit.parse("dm") works just the same way as DECI(METRE).toString(), but the result of
DECI(CARAT).toString() fails parsing it with AbstractUnit.parse("dct").
Note CARAT is defined by the extension module Unicode CLDR, but it should not really matter if the unit is defined by the RI itself or an extension.

@keilw keilw changed the title SimpleUnitFormat.parse() sometimes does not work with prefixes SimpleUnitFormat.parse() does not always work with prefixes Apr 17, 2021
@keilw keilw added this to the 2.1.3 milestone Apr 20, 2021
@keilw keilw removed this from the 2.1.3 milestone May 21, 2021
@cmmercer
Copy link

cmmercer commented Dec 8, 2021

I have also encountered this when using a custom unit (of geologic time, the "annus" with symbol "a") that I defined in my own SystemOfUnits. I took care to register a label with SimpleUnitFormat, so I can parse it when the unit does not have a prefix. But when I instantiate the unit with a metric prefix and try to parse the result of calling toString() (e.g., "Ma" or "ka") it fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants