long money1 = Math.round(money * 100); // 四舍五入到分
if (money1 == 0)
return “零元整”;
String strMoney = String.valueOf(money1);
int numIndex = 0; // numIndex用于选择金额数值
int unitIndex = UNIT.length - strMoney.length(); // unitIndex用于选择金额单位
boolean isZero = false; // 用于判断当前为是否为零
String result = “”;
for (; numIndex < strMoney.length(); numIndex++, unitIndex++) {
char num = strMoney.charAt(numIndex);
if (num == ‘0’) {
isZero = true;
if (UNIT[unitIndex] == “亿” || UNIT[unitIndex] == “万”
|| UNIT[unitIndex] == “元”) { // 如果当前位是亿、万、元,且数值为零
result = result + UNIT[unitIndex]; //补单位亿、万、元
isZero = false;
}
}else {
if (isZero) {
result = result + “零”;
isZero = false;
}
result =