将银行大写数字转换为纯数字
2018-07-20 来源:open-open
/** * * @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; }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
下一篇:A*算法Java简单实现
最新资讯
热门推荐