Java tutorial
//package com.java2s; import java.text.DecimalFormat; public class Main { /** * Number format. * * @param v * the v * @return the string */ public static String numberFormat(double v) { if (v == 0.0) { return "0.00"; } DecimalFormat nf = new DecimalFormat("#.##"); nf.applyPattern("0.00"); return nf.format(v); } }