Here you can find the source of formatPercent(double v)
public static String formatPercent(double v)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; public class Main { public static String formatPercent(double v) { return formatPercent(new Double(v)); }/*from w w w . j a va 2 s. co m*/ public static String formatPercent(Double v) { if (v == null) { return null; } return doubleFormat(v * 100) + "%"; } /** * Formats a double to two decimal places * * @param d Double to format * @return Formatted double */ public static String doubleFormat(Double d) { return doubleFormat(d, 0); } public static String doubleFormat(double d) { return doubleFormat(new Double(d)); } public static String doubleFormat(Double d, int minFraction) { if (d == null) { return null; } NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); if (minFraction > 0) { nf.setMinimumFractionDigits(minFraction); } return nf.format(d); } public static String doubleFormat(double d, int minFraction) { return doubleFormat(new Double(d), minFraction); } }