Here you can find the source of format2Money(double value)
public static String format2Money(double value)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; import java.text.NumberFormat; public class Main { /** EMPTY [String] */ public static final String EMPTY = ""; public static NumberFormat format = new DecimalFormat("0"); public static NumberFormat format2 = new DecimalFormat("0.00"); public static String format2Money(double value) { return format2.format(value); }/* ww w. ja v a 2 s . c o m*/ public static String format(Object object) { if (object instanceof Double) { return formatDouble((Double) object); } else { Double val = toDouble(object); if (val != null) { return formatDouble(val); } } return EMPTY; } public static String formatDouble(double value) { return format.format(value); } public static Double toDouble(Object value) { try { if (value == null || EMPTY.equals(value)) { return null; } return Double.valueOf(value.toString()); } catch (Exception e) { e.printStackTrace(); return null; } } }