/**
* 移除小数点后没有意义的 0
* <pre>
* 1230.00 => 1230
* 1230.10 => 1230.1
* =====以下是不变的=====
* 123000 => 123000
* 1230.01 => 1230.01
* </pre>
*/
public static String removeLastZero(String str) {
if(str==null){
return str;
}
if (!str.contains(".")) {
return str;
}
str = str.replaceAll("0+?$", "");
return str.replaceAll("[.]$", "");
}
移除小数点后没有意义的 0
最新推荐文章于 2024-08-24 17:09:16 发布