NumberFormat nt = NumberFormat.getPercentInstance(); //设置百分数精确度2即保留两位小数 nt.setMinimumFractionDigits(2); //最后格式化并输出 return nt.format(float or double的数据);
代码不多直接贴上