Here you can find the source of format(Object money)
public static String format(Object money)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; import java.text.DecimalFormat; public class Main { private static final String CURRENCY_FORMAT = "#,#00.00#"; public static String format(Object money) { return format(money, CURRENCY_FORMAT); }//from w ww . ja v a 2 s .com public static String format(Object money, String formatReg) { DecimalFormat df = new DecimalFormat(formatReg); return df.format(new BigDecimal(_getStrMoney(money)).doubleValue()).toString().replaceAll("^0(\\d).(\\d+)$", "$1.$2"); } private static String _getStrMoney(Object money) { String strMoney = "0"; if (money != null) { strMoney = money.toString(); if (strMoney.equals("")) strMoney = "0"; } return strMoney; } }