public static String getNumberStr(int num) {
if (num < 0) {
return “”;
}
if (num==0) {
return NUMBER1[0];
}
int split=10000;
int y=num / (split * split);
int w=(num / split) % split;
int g=num % split;
StringBuffer sb=new StringBuffer();
//亿
if (y > 0) {
sb.append(getNumberStr1000(y));
sb.append(NUMBER2[5]);
}
//万
if (w > 999) {
sb.append(getNumberStr1000(w));
sb.append(NUMBER2[4]);
} else {
if (w > 0) {
if (y !=0) {
sb.append(NUMBER2[0]);
}
sb.append(getNumberStr1000(w));
sb.append(NUMBER2[4]);
}
}
//万以下
if (g > 0) {
if (w !=0) {
if (g > 999) {
sb.append(getNumberStr1000(g));
} else {
sb.append(NUMBER2[0]);
sb.append(getNumberStr1000(g));
}
public static String getNumberStr(int num) {
if (num < 0) {
return “”;
}
if (num==0) {
return NUMBER1[0];
}
int split=10000;
int y=num / (split * split);
int w=(num / split) % split;
int g=num % split;
StringBuffer sb=new StringBuffer();
//亿
if (y > 0) {
sb.append(getNumberStr1000(y));
sb.append(NUMBER2[5]);
}
//万
if (w > 999) {
sb.append(getNumberStr1000(w));
sb.append(NUMBER2[4]);
} else {
if (w > 0) {
if (y !=0) {
sb.append(NUMBER2[0]);
}
sb.append(getNumberStr1000(w));
sb.append(NUMBER2[4]);
}
}
//万以下
if (g > 0) {
if (w !=0) {
if (g > 999) {
sb.append(getNumberStr1000(g));
} else {
sb.append(NUMBER2[0]);
sb.append(getNumberStr1000(g));
}
} else {
if (y !=0) {
sb.append(NUMBER2[0]);
}
sb.append(getNumberStr1000(g));
}
}
return sb.toString();
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。