-3

Previously we using formatter= NumberFormat.getCurrencyInstance(Locale.US); we getting $12.50.Now we don't want $ sign so i used formatter = NumberFormat.getNumberInstance(Locale.US); but getting value 12.5 instead of 12.50 formatter.setMinimumFractionDigits(2); are used but no use.I observed that for (1-9) getting like 12.01,12.02 upto 12.09 for "12.10" it is printing "12.1".Like wise 12.21 coming normally for "12.20" getting "12.2".

2 Answers2

0

actually u can archive the result with:

NumberFormat fn = NumberFormat.getNumberInstance(Locale.US);
fn.setMinimumFractionDigits(2);
System.out.println(fn.format(12.50));
Erinas
  • 45
  • 9
0

You can use the String.format method as well:

String.format(Locale.US, "%.2f", value );
loic
  • 151
  • 1
  • 4