Here you can find the source of formatFloat(Float f, int style)
public static String formatFloat(Float f, int style)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; import java.util.Locale; public class Main { public static final int FORMAT_INTEGER = 2; public static final int FORMAT_PERCENT = 3; public static String formatFloat(Float f, int style) { String num = new String("0"); if (f != null) num = new String(f.toString()); else//from w ww .ja v a 2 s. c o m return ""; NumberFormat nf = null; switch (style) { case FORMAT_INTEGER: { nf = NumberFormat.getIntegerInstance(Locale.US); num = nf.format(Double.parseDouble(f.toString())); break; } case FORMAT_PERCENT: { nf = NumberFormat.getPercentInstance(Locale.US); num = nf.format(Double.parseDouble(f.toString())); break; } default: { nf = NumberFormat.getCurrencyInstance(Locale.US); num = nf.format(Double.parseDouble(f.toString())); } } return num; } }