zoukankan      html  css  js  c++  java
  • 将银行大写数字转换为纯数字

    原文:http://www.open-open.com/code/view/1434531522458

     /** 
             *  
             * @Description: 将“壹仟”格式转换成1000 
             * @param 
             * @return int 
             * @throws 
             */  
            public static int getMoneyFromString(String string) {  
          
                int result = 0;  
          
                if (string.contains("亿")) {  
                    int index = string.indexOf("亿");  
                    char billionString = string.charAt(index - 1);  
                    result = result + getNumFromOldString(billionString) * 10000;  
                }  
          
                if (string.contains("仟")) {  
                    int index = string.indexOf("仟");  
                    char millionString = string.charAt(index - 1);  
                    result = result + getNumFromOldString(millionString) * 1000;  
                }  
          
                if (string.contains("佰")) {  
                    int index = string.indexOf("佰");  
                    char hundredString = string.charAt(index - 1);  
                    result = result + getNumFromOldString(hundredString) * 100;  
                }  
          
                if (string.contains("拾")) {  
                    int index = string.indexOf("拾");  
                    char tenString = string.charAt(index - 1);  
                    result = result + getNumFromOldString(tenString) * 10;  
                }  
          
                String[] lastNum = string.split("拾");  
                if (lastNum.length > 1) {  
                    result = result + getNumFromOldString(lastNum[1].toCharArray()[0]);  
                }  
          
                return result;  
          
            }  
          
            /** 
             *  
             * @Description: 转换老体字到数字 
             * @param 
             * @return int 
             * @throws 
             */  
            public static int getNumFromOldString(char ch) {  
          
                switch (ch) {  
                case '零':  
                    return 0;  
                case '壹':  
                    return 1;  
                case '贰':  
                    return 2;  
                case '叁':  
                    return 3;  
                case '肆':  
                    return 4;  
                case '伍':  
                    return 5;  
                case '陆':  
                    return 6;  
                case '柒':  
                    return 7;  
                case '捌':  
                    return 8;  
                case '玖':  
                    return 9;  
                }  
          
                return 0;  
          
            }  
  • 相关阅读:
    BOM and DOM
    css
    HTML
    数据库
    线程
    进程.
    粘包的高大上版本
    2015.3.10(自适应屏幕和弹性布局)
    2015.3.9小练习(投票百分比jquery)
    2015.3.9小练习(无刷新留言板)
  • 原文地址:https://www.cnblogs.com/shihaiming/p/7048524.html
Copyright © 2011-2022 走看看