public static String getHanStr(String number) {
StringBuffer sb = new StringBuffer();
String[] numArr = { "", "일", "이", "삼", "사", "오", "육", "칠", "팔", "구" };
// 16자리 어레이로 만들기
try{
int len = number.length();
if (len > 16){ throw new Exception("자릿수가 초과했습니다"); }
int[] snum = new int[16];
for (int i = (snum.length - (len)); i < snum.length; i++){
int k = i - (snum.length - len);
String a = String.valueOf(number.charAt(k));
snum[i] = Integer.parseInt(a);
}
for (int j = 0; j < 4; j++){
int k = (j * 4);
if (snum[k] + snum[k + 1] + snum[k + 2] + snum[k + 3] > 0){
if (snum[k] > 0){
sb.append(numArr[snum[k]]).append("천");
}
if (snum[k + 1] > 0){
sb.append(numArr[snum[k + 1]]).append("백");
}
if (snum[k + 2] > 0){
sb.append(numArr[snum[k + 2]]).append("십");
}
if (snum[k + 3] > 0){
sb.append(numArr[snum[k + 3]]);
}
switch (j) {
case 0:
sb.append("조");
break;
case 1:
sb.append("억");
break;
case 2:
sb.append("만");
break;
case 3:
sb.append("원");
break;
}
}
}
return sb.toString();
}catch(NumberFormatException e){
return "";
}catch(Exception e){
return "";
}
}