Java BigDecimal Format formatBigDecimal(BigDecimal valor, int decimal)

Here you can find the source of formatBigDecimal(BigDecimal valor, int decimal)

Description

Formata um Big Decimal

License

Open Source License

Parameter

Parameter Description
valor a parameter
decimal a parameter

Declaration

public static final String formatBigDecimal(BigDecimal valor, int decimal) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;

import java.text.NumberFormat;

import java.util.Locale;

public class Main {
    /**/* www . j a v  a 2 s .c  om*/
     * Formata um Big Decimal
     * @param valor
     * @param decimal
     * @return
     */
    public static final String formatBigDecimal(BigDecimal valor, int decimal) {
        if (valor == null) {
            return null;
        }
        NumberFormat format = NumberFormat.getInstance(new Locale("pt", "BR"));
        format.setMaximumFractionDigits(decimal);
        format.setMinimumFractionDigits(decimal);
        return format.format(valor);
    }
}

Related

  1. formatBigDecimal(BigDecimal bigDecimal)
  2. formatBigDecimal(BigDecimal bigDecimal, int scale)
  3. formatBigDecimal(BigDecimal d)
  4. formatBigDecimal(BigDecimal n, int dp)
  5. formatBigDecimal(BigDecimal number, int val)
  6. formatBigDecimal(BigDecimal value, char thousandSep, char decimalPoint, int numDecimals)
  7. formatBigDecimal(String value)
  8. formatBigDecimalWithPrecise(BigDecimal number)
  9. formatCents(int cents)