Android examples for java.lang:Float
Format float type fraction Number
import java.text.NumberFormat; public class Main { public static String fractionNumber(float number, int maxFractionDigits) { NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(maxFractionDigits); return nf.format(number); }//from w ww . j a v a 2s . com }