Search This Blog

Tuesday, November 13, 2018

How to output float data with 2 decimal places in Java

DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
System.out.println(df.format(decimalNumber));
Another one is to construct it using the #.## format.