Java BigDecimal Format format2Scale(BigDecimal obj)

Here you can find the source of format2Scale(BigDecimal obj)

Description

format Scale

License

Open Source License

Declaration

public static String format2Scale(BigDecimal obj) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {
    public static final int ROUNDING_MODE = BigDecimal.ROUND_HALF_UP;

    public static String format2Scale(BigDecimal obj) {
        if (obj != null) {
            return obj.setScale(2, ROUNDING_MODE).toPlainString();
        } else {//from w w w  .  j  av  a  2s . c om
            return "";
        }
    }
}

Related

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