Somewhat related to this question and several other SO questions relating to formatting decimals (all of which did not help me in this instance).
I am trying to format a Long into a String e.g. 123456 -> 012.345,6 (period followed by comma as strange as it may seem, it's a project requirement).
I am experimenting with DecimalFormat for the formatting:
private static final DecimalFormat format = new DecimalFormat("##0.000,0");
However it throws an exception during instantiation:
java.lang.IllegalArgumentException: Malformed pattern "##0.000,0"
I have also experimented with changing the locale to an EU system beforehand e.g.
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.GERMAN);
How can I format numbers in this way? Is DecimalFormat the wrong solution? Can I use a NumberFormat? Or will I need a custom formatter?