NumberFormat nt = NumberFormat.getPercentInstance();
//设置百分数精确度2即保留两位小数
nt.setMinimumFractionDigits(2);
//最后格式化并输出
return nt.format(float or double的数据);
代码不多直接贴上
NumberFormat nt = NumberFormat.getPercentInstance();
//设置百分数精确度2即保留两位小数
nt.setMinimumFractionDigits(2);
//最后格式化并输出
return nt.format(float or double的数据);
代码不多直接贴上
转载于:https://www.cnblogs.com/marx-luo/p/6713108.html