From 921bf2ab1d532ea5a84111fd534bdfa939468132 Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Tue, 21 Nov 2023 10:41:11 +0900 Subject: [PATCH] =?UTF-8?q?=EC=88=AB=EC=9E=90=EB=A5=BC=20=ED=95=9C?= =?UTF-8?q?=EA=B8=80=EB=A1=9C=20=ED=91=9C=EC=8B=9C=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cokr/xit/fims/cmmn/CmmnUtil.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java index b9f4e370..d0113515 100644 --- a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java @@ -287,4 +287,34 @@ public class CmmnUtil { DecimalFormat decFormat = new DecimalFormat("###,###"); return decFormat.format(number); } + + /** 숫자를 한글로 표시한다. + * @param number + * @return + */ + public static String convertNumberToHangul(String number) { + String[] han1 = { "", "일", "이", "삼", "사", "오", "육", "칠", "팔", "구" }; + String[] han2 = { "", "십", "백", "천" }; + String[] han3 = { "", "만", "억", "조", "경" }; + String result = ""; + int len = number.length(); + int nowInt = 0; + boolean hasHan3 = false; + for (int i = len; i > 0; i--) { + nowInt = Integer.parseInt(number.substring(len - i, len - i + 1)); + int han2Pick = (i - 1) % 4; + if (nowInt > 0) { + result += (han1[nowInt]) + (han2[han2Pick]); + if (han2Pick > 0) { + hasHan3 = false; + } + } + if (!hasHan3 && han2Pick == 0) { + result += (han3[(i - 1) / 4]); + hasHan3 = true; + } + } + return result.toString(); + } + }