1.小数格式化后转字符串百分数(带%)输出 

NumberFormat nt = NumberFormat.getPercentInstance();
//设置百分数精确度2即保留两位小数
nt.setMinimumFractionDigits(1);
//值 
String str= nt.format(100.0012);

2.小数格式化后转成几位字符串小数输出

DecimalFormat dff = new DecimalFormat("0.0");//格式化小数
String num = dff.format((double)123.12);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2021-12-03
  • 2022-02-05
猜你喜欢
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案