Here you can find the source of getPercentString(double numerator, double denominator)
public static String getPercentString(double numerator, double denominator)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; public class Main { private static final NumberFormat FORMAT_PERCENT = NumberFormat.getNumberInstance(); public static String getPercentString(double numerator, double denominator) { if (denominator == 0) { return "0.00%"; }/*from w w w . j a v a2s . com*/ return FORMAT_PERCENT.format((numerator / denominator) * 100) + "%"; } }