I want to truncate a float and a double value in java.
Following are my requirements: 1. if i have 12.49688f, it should be printed as 12.49 without rounding off 2
take a look with DecimalFormat() :
DecimalFormat()
DecimalFormat df = new DecimalFormat("#.##"); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setDecimalSeparator(','); df.setDecimalFormatSymbols(dfs);