Java tutorial
//package com.java2s; import java.text.DecimalFormat; public class Main { public static String formatString(double text) { DecimalFormat df = new DecimalFormat("0.##"); String str = df.format(text); return str; } public static String formatString(Object text) { DecimalFormat df = new DecimalFormat("0.##"); String str = df.format(text); return str; } }