/** 百分比 参1/参2 **/
String getPercent(String s1,String s2){
String sResult = "";
if(StrUtil.isBlank(s2) || s2.equals("0") || Integer.valueOf(s2) == 0) return "0%";
java.text.NumberFormat numberFormat=java.text.NumberFormat.getInstance();
numberFormat.setMaximumFractionDigits(2); //设置精确到小数点后2位
//sResult=numberFormat.format((float)lstCustomerInfoTenancy.size()/(float)lstCustomerInfo.size()*100)+"%";
sResult=numberFormat.format(Float.valueOf(s1)/Float.valueOf(s2)*100)+"%";
return sResult;
}
标签:百分比,java,String,numberFormat,s2,valueOf,sResult
From: https://www.cnblogs.com/linhan8888/p/17567315.html