Is there a way to localize a number and unit like 1,234.56GB using a locale-specific formatter?
There are languages in which there should be a space between the number and the unit, such as Norwegian and Finnish (in addition to the difference in the formatting of the number itself).
Expected Result:
Norwegian - 1 234,56 GB (There should be a space before GB)
English - 1,234.56GB
My code:
double val = 1234.1744689941406;
String mb = "MB";
NumberFormat nf = NumberFormat.getNumberInstance(new Locale("no"));
DecimalFormat df = (DecimalFormat)nf;
df.applyPattern("###,###.##");
df.setPositiveSuffix("MB");
String output = df.format(val);
But this is giving me a result of 1 234,56GB.