Here you can find the source of formatPercent(double p_double, int p_decimals)
Parameter | Description |
---|---|
p_double | The double to be interpreted as a percent |
p_decimals | The number of decimals to use |
public static String formatPercent(double p_double, int p_decimals)
//package com.java2s; //License from project: Open Source License import java.text.NumberFormat; public class Main { /**//from w ww . j a v a 2 s . c om * Formats a percent as a string in a standard way * @param p_double The double to be interpreted as a percent * @param p_decimals The number of decimals to use * @return The formatted string */ public static String formatPercent(double p_double, int p_decimals) { NumberFormat format = NumberFormat.getPercentInstance(); format.setMinimumFractionDigits(p_decimals); return format.format(p_double); } }