Java float type format via DecimalFormat
public class Main { public static void main(String[] args) { float number = 123.1465f; DecimalFormat decimalFormat = new DecimalFormat("#.00"); String numberAsString = decimalFormat.format(number); System.out.println(numberAsString); //from w ww .j a v a 2 s . co m decimalFormat = new DecimalFormat("#,##0.00"); numberAsString = decimalFormat.format(number); System.out.println(numberAsString); System.out.println(decimalFormat.format(123456.123456)); System.out.println(decimalFormat.format(98754.987654)); } }