2018-08-08 17:14:18 +08:00

25 lines
657 B
Java

package com.tenwa.app.invoice.utils;
public class Num2ChineseUtil {
public static String format(String string) {
String[] s1 = { "", "", "", "", "", "", "", "", "", "" };
String[] s2 = { "", "", "", "", "", "", "", "亿", "", "", "" };
String result = "";
int n = string.length();
for (int i = 0; i < n; i++) {
int num = string.charAt(i) - '0';
if (i != n - 1 && num != 0) {
result += s1[num] + s2[n - 2 - i];
} else {
result += s1[num];
}
}
return ""+result+"";
}
}