How to format negative numbers in accounting notation via ec.l10n.formatCurrency in Java 11

I know I’m late to the party of moving from Java 8 to 11…but, we have some clients that remain on JDK 8 and I’m running an Apple Silicon Mac, OpenJDK 11.

For check stubs, we had been using ec.l10n.formatCurrency, which caused negative numbers to appear in parentheses, but on OpenJDK 11, I’m now seeing a negative sign instead.

Is there a solution I can do that will work for both so as to continue using the () notation for negative numbers?

I’m not sure if it works in 8…but I can do the following on formatCurrency…but I’d like to find a better hammer if there is one than forcing it.

            NumberFormat nf = NumberFormat.getCurrencyInstance(locale);
            ((DecimalFormat) nf).setNegativePrefix("(");
            ((DecimalFormat) nf).setNegativeSuffix(")");
            nf.setCurrency(currency);

That also seems to drop the currency unfortunately.

It is unfortunate they changed that… yes, we may have to do something manual or find another library that does number formatting with sufficient options.

Have you started looking in that direction at all? I suppose for this specific number formatting need a little custom code would take less time than even trying to find a library, but for more general stuff Moqui may need an alternative is the Java NumberFormat stuff isn’t going to be reliable.

For the moment, it is just a handful of .ftl documents that utilize it, so I’ll just go the route of specifying the format I need for them.

NumberFormat has a pattern, that may be a route to go, but seems maybe more involved across currencies and such.