Java tutorial
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { /** * formatCurrency * @param amount the double amount to format as currency * @return the USD value */ public static String formatCurrency(double amount) { DecimalFormat dFormat = new DecimalFormat("#.00"); return ("$" + dFormat.format(amount)); } }