Double类型,转百分数,代码如下:
public static String getPercentValue( double similarity){ NumberFormat fmt = NumberFormat.getPercentInstance(); fmt.setMaximumFractionDigits(2);//最多两位百分小数,如25.23% return fmt.format(similarity); }
Float类型,转百分数,代码如下:
public static String getPercentValue( float similarity){ NumberFormat fmt = NumberFormat.getPercentInstance(); fmt.setMaximumFractionDigits(2);//最多两位百分小数,如25.23% return fmt.format(similarity); }
来源:CSDN
作者:秋9
链接:https://blog.csdn.net/jlq_diligence/article/details/103955965