1 /** 2 * 获取两个数百分比的值 3 * 4 * @param num1 5 * @param num2 6 * @param retain 保留小数位数 7 * @return 8 */ 9 public static String numberFormat(int num1, int num2, int retain) { 10 NumberFormat numberFormat = NumberFormat.getInstance(); 11 numberFormat.setMaximumFractionDigits(retain); 12 String result = numberFormat.format((float) num1 / (float) num2 * 100); 13 return result; 14 }