Java BigDecimal Format formatDecimalCost(BigDecimal value)

Here you can find the source of formatDecimalCost(BigDecimal value)

Description

format Decimal Cost

License

Open Source License

Declaration

public static String formatDecimalCost(BigDecimal value) 

Method Source Code

//package com.java2s;
/*// ww w .  j av a  2s.c o  m
 * Copyright (c) 2004-2012 The YAWL Foundation. All rights reserved.
 * The YAWL Foundation is a collaboration of individuals and
 * organisations who are committed to improving workflow technology.
 *
 * This file is part of YAWL. YAWL is free software: you can
 * redistribute it and/or modify it under the terms of the GNU Lesser
 * General Public License as published by the Free Software Foundation.
 *
 * YAWL 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 Lesser General
 * Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with YAWL. If not, see <http://www.gnu.org/licenses/>.
 */

import java.math.BigDecimal;

import java.text.DecimalFormat;
import java.text.NumberFormat;

import java.util.*;

public class Main {

    public static String formatDecimalCost(BigDecimal value) {
        Currency currency = Currency.getInstance(Locale.getDefault());
        NumberFormat fmt = DecimalFormat.getInstance();
        fmt.setMinimumFractionDigits(2);
        fmt.setMaximumFractionDigits(2);
        return currency.getSymbol() + fmt.format(value);
    }
}

Related

  1. formatCents(int cents)
  2. formatCUBRIDNumber(BigDecimal value)
  3. formatDecimal(BigDecimal b)
  4. formatDecimal(BigDecimal num)
  5. formatDecimal(BigDecimal number, int maxFractionDigits, int minFractionDigits)
  6. formatDigit(double value, int scale)
  7. formatDouble(double d)
  8. formatDouble(Double someDouble, int digitsToTheRightOfDecimal)
  9. formatDouble(Double toFormat)