개발환경

숫자를 문자로 변환하기.

toogari 2019. 9. 2. 11:54
        <dependency>
            <groupId>com.ibm.icu</groupId>
            <artifactId>icu4j</artifactId>
            <version>64.2</version>
        </dependency>

icu4j 로 깔끔하게 처리가능합니다.

 

 

        ULocale locale = new ULocale(Locale.KOREA.toString());
        Double d = Double.parseDouble("123456789");
        NumberFormat formatter = new RuleBasedNumberFormat(locale, RuleBasedNumberFormat.SPELLOUT);
        String result = formatter.format(d);
        System.out.println(result);