Java Decimal Format decimal2percent(double decimal, int pos)

Here you can find the source of decimal2percent(double decimal, int pos)

Description

decimalpercent

License

Apache License

Declaration

public static String decimal2percent(double decimal, int pos) 

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();

    public static String decimal2percent(double decimal, int pos) {
        NumberFormat nt = NumberFormat.getPercentInstance();
        nt.setMinimumFractionDigits(pos);
        return nt.format(decimal);
    }//from w  w w. ja  v  a  2  s.  c om

    /**
     * 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. addDouble(Integer i, Double d)
  2. adjust(Double lng, Double lat, Double distance, Double angle)
  3. adjustDoubleNumber(Double doubleNumber, int maxIntPart, int maxFloatPart)
  4. createMeanRmsString(double values[])
  5. decimal2string(BigDecimal arg, Locale loc)
  6. decimalConversation(double amount)
  7. decimalFormat()
  8. decimalFormat(double d)