具体代码如下
double a = 123456;
double b = 123456.78999;
DecimalFormat df = new DecimalFormat("#.000");
System.out.println(df.format(a / 1000));
System.out.println(df.format(b / 1000));
打印结果如下
来源:CSDN
作者:胡小牧
链接:https://blog.csdn.net/qq_33210042/article/details/103997847