Java Utililty Methods Currency Format

List of utility methods to do Currency Format

Description

The list of methods to do Currency Format are organized into topic(s).

Method

Stringcurrency(double amount, String language, String country)
Format a currency amount in a given locale.
Locale locale = null;
if (language == null || country == null) {
    locale = Locale.getDefault();
} else {
    locale = new Locale(language, country);
return currency(amount, locale);
Stringcurrency(double amount, String language, String country)
Format a currency amount for a given language and country.
Locale locale = getLocale(language, country);
return currency(amount, locale);
Stringcurrency(double value, NumberFormat nformat)
Converts a number representing dollars to a currency display string using the supplied number format.
return nformat.format(value);
NumberFormatcurrencyFormat()
currency Format
NumberFormat format = NumberFormat.getNumberInstance();
format.setMaximumFractionDigits(2);
format.setMinimumFractionDigits(2);
return format;
Stringformat2CurrencyWithComma(double amt)
format Currency With Comma
String formattedAmount = format2DecimalPointMoneyWithComma(amt);
if (formattedAmount.startsWith("(")) {
    return formattedAmount.replace("(", "($");
} else {
    return "$" + formattedAmount;
StringformatAsCurrency(BigDecimal nAmount)
Formatea cantidades como moneda utilizando el default locale.
return nfCurrency.format(nAmount);
StringformatAsCurrency(final double value)
format As Currency
String str = dFormat.format(value);
if (str.endsWith(".00")) {
    str = str.substring(0, str.length() - 3);
return str;
StringformatAsCurrency(Number amount)
Convenience method for converting Number to currency string representation with minimal overhead.
return amount == null ? "" : CURRENCY_FORMAT.get().format(amount);
StringformatAsCurrency(Number value)
format As Currency
if (value == null) {
    return "";
return currencyFormat.format(value);
StringformatCurrency(BigDecimal amount)
format Currency
if (amount.compareTo(BigDecimal.ZERO) <= 0) {
    return "0";
DecimalFormat df = new DecimalFormat("#,###.00");
return df.format(amount);