Java Utililty Methods BigDecimal Format

List of utility methods to do BigDecimal Format

Description

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

Method

StringformatAsReadable(BigDecimal number)
Formats the given BigDecimal to a readable String.
return humanReadableFormat.format(number);
StringformatBetrag(BigDecimal bdBetrag, Locale locale)
Einen Betrag localeabhaengig formatieren.
return NumberFormat.getCurrencyInstance(locale).format(bdBetrag.doubleValue());
StringformatBigDecimal(BigDecimal bd, NumberFormat format)
Formatteert bd volgens format.
if (bd == null) {
    return "";
} else {
    return format.format(bd.doubleValue());
StringformatBigDecimal(BigDecimal bigDecimal)
Formats a BigDecimal to a String according to JVM Locale.
DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.getDefault());
String result = String.valueOf(bigDecimal.doubleValue());
result = result.replace('.', dfs.getDecimalSeparator());
return result;
StringformatBigDecimal(BigDecimal bigDecimal, int scale)
Formate un big decimal
if (scale != formaterScale)
    initializeDecimalFormat(scale);
return decimalFormater.format(bigDecimal.doubleValue());
StringformatBigDecimal(BigDecimal d)
Method for adding trailing zeroes for a BigDecimal value
DecimalFormat df = new DecimalFormat("#.##");
df.setMinimumFractionDigits(2);
return df.format(d);
BigDecimalformatBigDecimal(BigDecimal n, int dp)
Sets [n] to [dp] decimal places.
return n.setScale(dp, BigDecimal.ROUND_HALF_UP); 
StringformatBigDecimal(BigDecimal number, int val)
format Big Decimal
DecimalFormat nf = new DecimalFormat();
nf.setMaximumFractionDigits(val);
nf.setMinimumFractionDigits(val);
nf.setRoundingMode(RoundingMode.HALF_UP);
nf.setGroupingUsed(true);
return nf.format(number);
StringformatBigDecimal(BigDecimal valor, int decimal)
Formata um Big Decimal
if (valor == null) {
    return null;
NumberFormat format = NumberFormat.getInstance(new Locale("pt", "BR"));
format.setMaximumFractionDigits(decimal);
format.setMinimumFractionDigits(decimal);
return format.format(valor);
StringformatBigDecimal(BigDecimal value, char thousandSep, char decimalPoint, int numDecimals)
Format a BigDecimal, grouping thousands and rounding to a specified number of decimal digits.
if (numDecimals >= 0 && value.scale() != numDecimals) {
    value = value.setScale(numDecimals, BigDecimal.ROUND_HALF_UP);
String stringValue = value.toString();
int origLen = stringValue.length();
int decPoint = stringValue.indexOf('.');
int thousandSepCount;
boolean hasDecPoint;
...