欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

数字转人民币大写,转人民币大写,class RMB {

来源: javaer 分享于  点击 41881 次 点评:75

数字转人民币大写,转人民币大写,class RMB {


class RMB {    private static final char[] data = { '零', '壹', '贰', '叁', '肆', '伍', '陆',            '柒', '捌', '玖', '拾' };    private static final char[] units = { '圆', '拾', '佰', '仟', '万', '拾', '佰',            '仟', '亿', '拾', '佰', '仟','万' };    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;            char d = data[number];            if(d=='零'&&sbf.length()>0&&unit>1){                sbf.deleteCharAt(0);            }            sbf.insert(0, d);            money /= 10;        }        String moneyStr = sbf.toString();        while (moneyStr.indexOf("零零")>0) {            moneyStr = moneyStr.replaceAll("零零", "零");        }        return moneyStr.replace("零圆", "");    } }//该片段来自于http://byrx.net
相关栏目:

用户点评