float price=(float) 625.2135; DecimalFormat decimalFormat=new DecimalFormat(".00");//这里有几个0就保留几位,如果小数不足位,会以0补足. String price1=decimalFormat.format(price);//format 返回的是字符串 System.out.println(price1);
结果如下
float price=(float) 625.2135; DecimalFormat decimalFormat=new DecimalFormat(".00");//这里有几个0就保留几位,如果小数不足位,会以0补足. String price1=decimalFormat.format(price);//format 返回的是字符串 System.out.println(price1);
结果如下
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。