Here you can find the source of getF(String tStr, String formate)
public static String getF(String tStr, String formate)
//package com.java2s; import java.text.DecimalFormat; import java.text.FieldPosition; public class Main { private static DecimalFormat df = new DecimalFormat(); public static String getF(String tStr, String formate) { try {/*from w w w .j a v a2s . c om*/ df.applyPattern(formate); return format(tStr); } catch (Exception e) { return tStr; } } public static String format(String tStr) { StringBuffer sb = new StringBuffer(); df.format(Double.valueOf(tStr).doubleValue(), sb, new FieldPosition(df.INTEGER_FIELD)); return sb.toString(); } }