public String convertMoneyToHangul(String money) {
String[] han1 = {"","일","이","삼","사","오","육","칠","팔","구"};
String[] han2 = {"","십","백","천"};
String[] han3 = {"","만","억","조","경"};
StringBuffer result = new StringBuffer();
int len = money.length();
int nowInt = 0;
for(int i=len ; i > 0; i--){
nowInt = Integer.parseInt(String.valueOf(money.charAt(len - i)));
if(nowInt > 0){
result.append(han1[nowInt]);// 숫자
result.append(han2[i % 4]); // 십,백,천
}
// 만,억,조,경(4단위)
if(i % 4 == 0){
result.append(han3[i / 4]); // 천단위
result.append(" ");
}
}
return result.toString();
}
System.out.println(convertMoneyToHangul("12345678912"));