Is there a way to prevent the DecimalFormat object from automatically moving the decimal place two places to the right?
This code:
double d = 65.87; DecimalFormat df1 = new DecimalFormat(" #,##0.00"); DecimalFormat df2 = new DecimalFormat(" #,##0.00 %"); System.out.println(df1.format(d)); System.out.println(df2.format(d));
gives:
65.87 6,587.00 %
But I would like it to produce:
65.87 65.87 %
java decimalformat
ryvantage
source share