Java Currency Format formatCurrency(double num)

Here you can find the source of formatCurrency(double num)

Description

Formats a number to the currency used on the server.

License

Open Source License

Parameter

Parameter Description
num The number to format.

Return

The formatted number.

Declaration

public static String formatCurrency(double num) 

Method Source Code


//package com.java2s;
/*// w  w w  .  j av a2  s  . c om
 * This file is part of Mafiacraft.
 * 
 * Mafiacraft is released under the Voxton License version 1.
 *
 * Mafiacraft is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * In addition to this, you must also specify that this product includes 
 * software developed by Voxton.net and may not remove any code
 * referencing Voxton.net directly or indirectly.
 * 
 * Mafiacraft is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * and the Voxton license along with Mafiacraft. 
 * If not, see <http://voxton.net/voxton-license-v1.txt>.
 */

import java.text.NumberFormat;
import java.util.Locale;

public class Main {
    /**
     * Formats a number to the currency used on the server.
     *
     * @param num The number to format.
     * @return The formatted number.
     */
    public static String formatCurrency(double num) {
        return NumberFormat.getCurrencyInstance(Locale.US).format(num);
    }
}

Related

  1. formatCurrency(BigDecimal amount)
  2. formatCurrency(BigDecimal bd)
  3. formatCurrency(double amount)
  4. formatCurrency(double amount, int precision, Locale locale)
  5. formatCurrency(double amt)
  6. formatCurrency(Double number)
  7. formatCurrency(Double value)
  8. formatCurrency(final Double currencyValue, final Locale locale, final boolean isGroup)
  9. formatCurrency(Float amt)