NumberFormat num = NumberFormat.getPercentInstance();
num.setMaximumIntegerDigits(3);// 设置整数位最大为3位数
num.setMaximumFractionDigits(2);// 设置小数位最多为两位数

调用的时候,直接用

float a = 0f;

num.format(a);// 将a这个单精度浮点型小数格式化为百分数;

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
猜你喜欢
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2022-02-12
  • 2021-10-13
相关资源
相似解决方案