javamoney-examples
                                
                                 javamoney-examples copied to clipboard
                                
                                    javamoney-examples copied to clipboard
                            
                            
                            
                        Formatting using SYMBOL throws an exception
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)
Which version of the JSR/Moneta did you use to reproduce that?
With both 1.0.1-SNAPSHOT as well as 1.0.
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.
Ok, great. Thank you for the update.
Any update on this? Is this a problem the Moneta implementation?
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)));
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