Java BigDecimal Format format_BigDecimal(BigDecimal decimal, Integer scale)

Here you can find the source of format_BigDecimal(BigDecimal decimal, Integer scale)

Description

forma Big Decimal

License

Open Source License

Declaration

public static String format_BigDecimal(BigDecimal decimal, Integer scale) 

Method Source Code


//package com.java2s;
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    public static String format_BigDecimal(BigDecimal decimal, Integer scale) {
        if (decimal == null) {
            return null;
        }/*from   w  ww  .  j  a va2  s  . c o  m*/

        if (scale == null) {
            return decimal.toPlainString();
        }

        return decimal.setScale(scale, RoundingMode.HALF_UP).toPlainString();
    }
}

Related

  1. format(final BigDecimal bd)
  2. format(Object value, Integer precision)
  3. format(String pattern, final double secondInDouble)
  4. format2Scale(BigDecimal obj)
  5. format2String(BigDecimal bd)
  6. formatAmount(BigDecimal amount)
  7. formatAmount(BigDecimal amount)
  8. formatAmount(final BigDecimal number)
  9. formatAsReadable(BigDecimal number)