- public static String toChineseNum(long number) {
- long num1 = 0,num2 = 0;
- if (number == 0) {
- return "零";
- } else if (number == 1) {
- return "一";
- } else if (number == 2) {
- return "二";
- } else if (number == 3) {
- return "三";
- } else if (number == 4) {
- return "四";
- } else if (number == 5) {
- return "五";
- } else if (number == 6) {
- return "六";
- } else if (number == 7) {
- return "七";
- } else if (number == 8) {
- return "八";
- } else if (number == 9) {
- return "九";
- } else if (number == 10) {
- return "十";
- } else if (number > 99999999) {
- num1 = number/100000000;
- num2 = number%100000000;
- return toChineseNum(num1) + "亿" + ( num2==0?"":( (num2 < 10000000 ? "零":"") + toChineseNum(num2) ) );
- } else if (number > 9999 && number < 100000000) {
- num1 = number/10000;
- num2 = number%10000;
- return toChineseNum(num1) + "万" + ( num2 ==0?"":( (num2 < 1000 ? "零":"") + toChineseNum(num2)));
- } else if (number > 999 && number < 10000) {
- num1 = number/1000;
- num2 = number%1000;
- return toChineseNum(num1) + "千" + ( num2 ==0?"":( (num2 < 100 ? "零":"") + toChineseNum(num2)));
- } else if (number > 99 && number < 1000 ) {
- num1 = number/100;
- num2 = number%100;
- return toChineseNum(num1) + "百" + ( num2 ==0?"":( (num2 < 10 ? "零":"") + toChineseNum(num2)));
- } else if (number > 9 && number < 100) {
- num1 = number/10;
- num2 = number%10;
- return toChineseNum(num1) + "十" + ( num2 ==0?"":(toChineseNum(num2)));
- }
- return "";
- }
如何将阿拉伯数字转化为中文
最新推荐文章于 2023-09-27 00:29:55 发布