Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Thousand separator (space) not working when parsing #46

Closed
orousseil opened this issue May 15, 2018 · 7 comments
Closed

Thousand separator (space) not working when parsing #46

orousseil opened this issue May 15, 2018 · 7 comments

Comments

@orousseil
Copy link

Hello
The french thousand separator is the space character. When you parse a money amount with currency from a string it doesn't work !!

See this test case for example :

@Test
public void testParseKO() {
    MonetaryAmountFormat format = MonetaryFormats
            .getAmountFormat(AmountFormatQueryBuilder.of(Locale.FRANCE)
                    .set(CurrencyStyle.CODE)
                    .build());
    MonetaryAmount amountOk = format.parse("123,01 EUR");
    MonetaryAmount amountKo = format.parse("14 000,12 EUR");
    assertThat(amountOk.getNumber().doubleValueExact()).isEqualTo(123.01); // OK
    assertThat(amountKo.getNumber().doubleValueExact()).isEqualTo(14000.12); // KO
}
@keilw keilw added the analysis label May 15, 2018
@keilw
Copy link
Member

keilw commented May 15, 2018

Hi, thanks for bringing that up. Are you able to cross-check with the Java 8+ RI Moneta, if the same problem occurs there as well? It should be patched, but it's good to know, if it only affects one RI or both.

@orousseil
Copy link
Author

orousseil commented May 18, 2018

Sorry, i've post in the wrong project. I have originally detect this bug in the java 8+ implementation. So I don't know if the problem is the same for java 7 but it should. I will recreate an issue for the java 8+ github project (@see JavaMoney/jsr354-ri#193)

@keilw keilw added bug and removed analysis labels May 28, 2018
@keilw keilw added this to the 1.3 milestone May 28, 2018
@keilw keilw modified the milestones: 1.3, 1.4 Jul 15, 2018
@keilw keilw changed the title French thousand separator (space) not working when parsing Thousand separator (space) not working when parsing Dec 24, 2018
@keilw keilw pinned this issue Dec 24, 2018
@teobais
Copy link
Member

teobais commented Jun 27, 2019

Are we sure this is still the case after a year? I am not familiar enough with JSR-354, but this is what I'm getting when I run the fore-mentioned example against the latest HEAD:

javax.money.format.MonetaryParseException: Unparseable number: "123,01"

I haven't checked the codebase / debugged it thoroughly, but before going there, I wanted to check whether this is still the case or something change.

@orousseil could you please help me here? Does this issue still occur when you run your fore-mentioned case against the latest HEAD? Does it pass? Do you get the error I got or you only get an error? for the second/spacing case?

Or maybe I need to configure something in my IntelliJ for this particular case to fake the FR locale? I think configuring it programmatically in the test itself should be enough.

@keilw
Copy link
Member

keilw commented Jul 1, 2019

Please have a look at https://github.com/JavaMoney/jsr354-ri-bp/blob/master/src/test/java/org/javamoney/moneta/format/MonetaryFormatsTest.java. It seems that French locale might be treated properly now, check in detail in the test class, but there is nothing ignored at least not for this one. What's definitely open is #55.

@keilw
Copy link
Member

keilw commented Jul 18, 2019

@atsticks, @otaviojava IMO this really must be fixed, there are other minor things that the BP could neglect, but the two showstoppers including this one (which was fixed in the Java 8 RI) should be resolved before we are ready for MR1.

@keilw
Copy link
Member

keilw commented Aug 13, 2019

@thodorisbais if you try to parse "123,01" without a particular locale e.g. Germany or (is it the same there?) Netherlands, it is the right behavior, the default is English.

@teobais
Copy link
Member

teobais commented Aug 14, 2019

I need to check that, Werner. Hope I can make some time during the weekend.

@keilw keilw closed this as completed Mar 22, 2020
@keilw keilw unpinned this issue May 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants