给数字加上单位 万
public String getNum(String value) {
try {
double v = Double.parseDouble(value);
if (v > 10000) {
String str = String.valueOf(v / 10000);
return removeLast0(str) + "万";
} else {
return value;
}
} catch (Exception e) {
return value;
}
}
去掉后面的0
private String removeLast0(String string) {
if (string==null || string.length() == 0) {
return "0";}
try {
while (string.charAt(string.length() - 1) == '0') {
string = string.substring(0, string.length() - 1);
}
if (string.charAt(string.length() - 1) == '.') {
string = string.substring(0, string.length() - 1);
}
} catch (Exception e) {
return "";
}
return string;
}