这篇文章主要介绍了 java实现数字转大写的方法的相关资料,希望通过本文能帮助到大家,让大家实现这样的功能,需要的朋友可以参考下
java实现数字转大写的方法
说明:
将数字金额转大写,如下:
public class test {
/**
* @param args
* add by zxx ,nov 29, 2008
*/
private static final char[] data = new char[] { '零', '壹', '贰', '叁', '肆',
'伍', '陆', '柒', '捌', '玖' };
private static final char[] units = new char[] { '元', '拾', '佰', '仟', '万',
'拾', '佰', '仟', '亿' };
public static string convert(int money) {
stringbuffer sbf = new stringbuffer();
int unit = 0;
while (money != 0) {
sbf.insert(0, units[unit++]);
int number = money % 10;
sbf.insert(0, data[number]);
money /= 10;
}
return sbf.tostring();
}
/**
* @param args
*/
public static void main(string[] args) {
// todo auto-generated method stub
system.out.println(convert(135689123));
}
}
以上就是java数字转换成大写的实现方法详解的详细内容。