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

Formatting using SYMBOL throws an exception #25

Open
abhishek2bommakanti opened this issue Nov 4, 2015 · 7 comments
Open

Formatting using SYMBOL throws an exception #25

abhishek2bommakanti opened this issue Nov 4, 2015 · 7 comments

Comments

@abhishek2bommakanti
Copy link

Running the FormatExample class throws an exception when we try to run the US SYMBOL code:

Nov 04, 2015 11:46:45 AM org.javamoney.moneta.DefaultMonetaryContextFactory createMonetaryContextNonNullConfig
INFO: Using custom MathContext: precision=256, roundingMode=HALF_EVEN
Exception in thread "main" javax.money.MonetaryException: No MonetaryAmountFormat for AmountFormatQuery AmountFormatQuery (
{Query.formatName=SYMBOL, java.util.Locale=en_US})
at javax.money.spi.MonetaryFormatsSingletonSpi.getAmountFormat(MonetaryFormatsSingletonSpi.java:71)
at javax.money.format.MonetaryFormats.getAmountFormat(MonetaryFormats.java:110)
at org.javamoney.examples.console.functional.FormatExample.main(FormatExample.java:24)

@keilw
Copy link
Member

keilw commented Nov 4, 2015

Which version of the JSR/Moneta did you use to reproduce that?

@abhishek2bommakanti
Copy link
Author

With both 1.0.1-SNAPSHOT as well as 1.0.

@keilw
Copy link
Member

keilw commented Nov 4, 2015

Thanks, that indicates, it wasn't already fixed in master/1.0.1-SNAPSHOT.
We'll look into it, trying to reproduce and when the reason can be found address it in the 1.0.1 codebase. Once other pending issues with that are resolved, at least the RI and where necessary other modules will get a service pack.

@abhishek2bommakanti
Copy link
Author

Ok, great. Thank you for the update.

@rschanafelt
Copy link

Any update on this? Is this a problem the Moneta implementation?

@otaviojava
Copy link
Member

I ran this code, and it's fine.
I believe, it's already fixed.

        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        MonetaryAmountFormat fmt =
                MonetaryFormats.getAmountFormat (
                        AmountFormatQueryBuilder.of(Locale.US)
                                .set(symbols)
                                .build ());
        CurrencyUnit currencyUnit = Monetary.getCurrency(Locale.US);
        System.out.println(fmt.format(Money.of(10, currencyUnit)));

@axiopisty
Copy link

This appears to still be a problem. Is there any other solution? Please see my stack overflow question:

http://stackoverflow.com/questions/42098171/how-to-format-monetaryamount-with-currency-symbol

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

No branches or pull requests

5 participants