大写金额转数字
public Double CNYtoN(String amount) {
double result = 0;
double temp = -1;//存放一个单位的数字如:十万
int count = 0;//判断是否有chArr
Map<Character, Double> map = new HashMap<Character, Double>(); //存放数字map
map.put('壹', 1.0);
map.put('贰', 2.0);
map.put('叁', 3.0);
map.put('肆', 4.0);
map.put('伍', 5.0);
map.put('陆', 6.0);
map.put('柒', 7.0);
map.put('捌', 8.0);
map.put('玖', 9.0);
Map<Character, Double> map1 = new HashMap<Character, Double>(); //存放单位map
map1.put('拾', 10.0);
map1.put('佰', 100.0);
map1.put('仟', 1000.0);
map1.put('万', 10000.0);
map1.put('亿', 100000000.0);
map1.put('角', 0.1);
map1.put('分', 0.01);
map1.put('厘', 0.001);
for (int i = 0; i < amount.length(); i++) { //遍历属组
char c = amount.charAt(i);
if (map.containsKey(c)) {
if (temp != -1) {
result += temp;
temp = -1;
}
temp = map.get(c);
} else {
if (temp == -1) {
continue;
}
if (map1.containsKey(c)) {
temp *= map1.get(c);
}
}
if (i == amount.length() - 1) {
result += temp;
}
}
return result;
}