Here you can find the source of format(float value)
public static String format(float value)
//package com.java2s; import java.text.NumberFormat; public class Main { /** Used to easily format floats with sensible defaults. */ protected static final NumberFormat _ffmt = NumberFormat.getInstance(); /**/* w ww. jav a2 s .co m*/ * Formats a floating point value with useful default rules; ie. always display a digit to the * left of the decimal and display only two digits to the right of the decimal (rounding as * necessary). */ public static String format(float value) { return _ffmt.format(value); } /** * Formats a floating point value with useful default rules; ie. always display a digit to the * left of the decimal and display only two digits to the right of the decimal (rounding as * necessary). */ public static String format(double value) { return _ffmt.format(value); } }