Here you can find the source of formatCurrency(double amt)
Parameter | Description |
---|---|
amt | a parameter |
public static String formatCurrency(double amt)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; import java.util.Locale; public class Main { /**/*from w w w .j a va 2 s.co m*/ * Will format the currency according to the current users locale. * * @param amt * @return */ public static String formatCurrency(double amt) { return formatCurrency(amt, 2); } public static String formatCurrency(double amt, int fractionDigits) { return getCurrencyFormat(fractionDigits).format(amt); } public static NumberFormat getCurrencyFormat() { return getCurrencyFormat(2); } public static NumberFormat getCurrencyFormat(int fractionDigits) { NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); if (fractionDigits != 2) { nf.setMinimumFractionDigits(fractionDigits); nf.setMaximumFractionDigits(fractionDigits); } return nf; } }