Java BigDecimal Format formatBigDecimal(BigDecimal bigDecimal)

Here you can find the source of formatBigDecimal(BigDecimal bigDecimal)

Description

Formats a BigDecimal to a String according to JVM Locale.

License

Open Source License

Parameter

Parameter Description
bigDecimal a parameter

Declaration

public static String formatBigDecimal(BigDecimal bigDecimal) 

Method Source Code

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

import java.math.BigDecimal;

import java.text.DecimalFormatSymbols;

import java.util.Locale;

public class Main {
    /**//from   ww  w .  j  a  va 2  s . c om
     * Formats a BigDecimal to a String according to JVM Locale.
     * 
     * @param bigDecimal
     * @return
     */
    public static String formatBigDecimal(BigDecimal bigDecimal) {
        DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.getDefault());
        String result = String.valueOf(bigDecimal.doubleValue());
        result = result.replace('.', dfs.getDecimalSeparator());
        return result;
    }
}

Related

  1. formatAmount(BigDecimal amount)
  2. formatAmount(final BigDecimal number)
  3. formatAsReadable(BigDecimal number)
  4. formatBetrag(BigDecimal bdBetrag, Locale locale)
  5. formatBigDecimal(BigDecimal bd, NumberFormat format)
  6. formatBigDecimal(BigDecimal bigDecimal, int scale)
  7. formatBigDecimal(BigDecimal d)
  8. formatBigDecimal(BigDecimal n, int dp)
  9. formatBigDecimal(BigDecimal number, int val)