Java Percentage Format percentFormat(final BigDecimal bd)

Here you can find the source of percentFormat(final BigDecimal bd)

Description

return a Number formatted or empty string if null.

License

Apache License

Parameter

Parameter Description
bd a parameter

Declaration

public static String percentFormat(final BigDecimal bd) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;
import java.text.NumberFormat;

public class Main {
    private static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance();

    /**/*  www .  j ava  2 s. co m*/
     * return a Number formatted or empty string if null.
     * 
     * @param bd
     */
    public static String percentFormat(final BigDecimal bd) {
        return bd != null ? NUMBER_FORMAT.format(bd.movePointRight(2)) : "";
    }

    /**
     * return a Number formatted or empty string if null.
     * 
     * @param bd
     */
    public static String format(final BigDecimal bd) {
        return bd != null ? NUMBER_FORMAT.format(bd) : "";
    }
}

Related

  1. percentageAsString(double input)
  2. percentageFormat(BigDecimal value)
  3. percentDecimalFormat(final double no)
  4. percentFormat()
  5. percentFormat(BigDecimal interestRate)
  6. percentFormat(final double value)
  7. percentFormat(float value)
  8. percentFormat(Object object)
  9. percentTotal(double value, double total)