List of utility methods to do Percentage Format
String | calcPercent(double numerator, double denominator) calc Percent double fen = numerator / denominator; DecimalFormat df = new DecimalFormat("##0.00%"); return df.format(fen); |
String | formatAsPercent(double value, double maxValue, int fractionDigits) format As Percent return format(value * 100d / maxValue, fractionDigits, false) + "%"; |
String | formatDecimal(double percent) Rounds the number to the 4 decimal points NumberFormat formatter = new DecimalFormat("#0.0####"); return formatter.format(percent); |
String | formatDoubleAsPercentString(Double d) format Double As Percent String if (d == null) return null; return NumberFormat.getPercentInstance().format(d); |
String | formatMicrosAsPercentage(long micros) format Micros As Percentage BigDecimal percentage = new BigDecimal(micros).divide(MICROS_DIVISOR, 6, BigDecimal.ROUND_HALF_UP); return PERCENT_FORMAT.format(percentage); |
String | formatPercent(double done, int digits) Format a percentage for presentation to the user. DecimalFormat percentFormat = new DecimalFormat("0.00%"); double scale = Math.pow(10.0, digits + 2); double rounded = Math.floor(done * scale); percentFormat.setDecimalSeparatorAlwaysShown(false); percentFormat.setMinimumFractionDigits(digits); percentFormat.setMaximumFractionDigits(digits); return percentFormat.format(rounded / scale); |
String | formatPercent(Double num1, Double num2) format Percent if (num1 == null || num2 == null || num2 == 0) return ""; String format = "0.00%"; if (num1.intValue() == num1.doubleValue() && num2.intValue() == num2.doubleValue()) { format = "0%"; return formatPercent(num1, num2, format); |
String | formatPercent(double p_double, int p_decimals) Formats a percent as a string in a standard way NumberFormat format = NumberFormat.getPercentInstance(); format.setMinimumFractionDigits(p_decimals); return format.format(p_double); |
String | formatPercent(double percent) Format a number as a percent in the current locale. NumberFormat percentFormat = NumberFormat.getPercentInstance();
return percentFormat.format(percent);
|
String | formatPercent(double v) format Percent return formatPercent(new Double(v)); |