BigDecimal去掉小数位无效0并转换为String
//去掉小数位无效0并转换为String
public static String takeOutZero(BigDecimal data) {
int point = String.valueOf(data).indexOf(".");
if(point > 0){
String[] split = String.valueOf(data).split("");
int a = 0;
for (int i = split.length - 1; i >= point; i--) {
if (!split[i].equals("0")) {
a = i;
break;
}
}
StringBuilder dataStr = new StringBuilder();
for (int i = 0; i < a + 1; i++) {
if (i != a || !split[i].equals(".")) {
dataStr.append(split[i]);
}
}
return dataStr.toString();
}
return data.toString();
}