DecimalFormat df = new DecimalFormat(“###.00”);

  保留小数点后2位,但是当为0是显示为.00

这个时候需要用

String.format("%.2f",num);
//123.234  -----123.23
String.format("%,.2f",num);
//12345.23  -----12,345.23

  

相关文章:

  • 2021-10-16
  • 2021-10-24
  • 2021-09-13
  • 2021-09-16
  • 2021-08-17
  • 2021-10-30
  • 2021-11-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-08
  • 2021-07-07
  • 2021-11-15
  • 2022-02-19
  • 2022-12-23
相关资源
相似解决方案