Here you can find the source of formatAsCurrency(final double value)
public static String formatAsCurrency(final double value)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.Locale; public class Main { static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US)); public static String formatAsCurrency(final double value) { String str = dFormat.format(value); if (str.endsWith(".00")) { str = str.substring(0, str.length() - 3); }/*from w w w .j ava 2s. co m*/ return str; } }