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)); } }
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
新闻热点
疑难解答
图片精选