Here you can find the source of decimal2percent(double decimal, int pos)
public static String decimal2percent(double decimal, int pos)
//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) : ""; } }