Java将数字字符串转换成中文形式?
2009-10-31文字大小:大中小
public class MainClass3 {
/**
* @param args
* @deprecated 完成小数的中文转换
* @deprecated 核心工式:unit[(len - i - 1) % 8]
* @deprecated
* 1-0-1=0%8 亿
* 2-0-1=1%8 拾
* 3-0-1=2%8 佰
* 4-0-1=3%8 仟
* 5-0-1=4%8 万
* 6-0-1=5%8 拾
* 7-0-1=6%8 佰
* 8-0-1=7%8 仟
* 9-0-1=9%8 亿
*/
public static void main(String[] args) {
String temp0 = "987.65";// "009081";
String temp = temp0;
if (temp0.startsWith("0")) {
temp = String.valueOf(Integer.parseInt(temp0));
// System.out.println(Integer.parseInt(temp));
}
// int itemp = Integer.valueOf(temp);
// System.out.println("String --> Integer"+itemp);
StringBuffer retStrBuf = new StringBuffer();// 用来拼接数字串
int dot = 0; // 小数点位置
int ivalue = 0;// 保存每一个位上的数
int len = 0;// 保存数字的长度
for (int i = 0; i < temp.length(); i++) {
System.out.print(temp.substring(i, i + 1) + " ");
}
System.out.println();
String num[] = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
String unit[] = { "亿", "拾", "佰", "仟", "万", "拾", "佰", "仟" };
len = temp.length();
if (temp == null "".equals(temp) temp.length() <= 0) {
System.out.println("Input is null");