728x90
반응형

import java.text.DecimalFormat;

public class ExchangeFormat {
    public static void main(String[] ar) {
        double db = 154782600032546D;
        DecimalFormat d = new DecimalFormat("#,####");
       
        String[] unit = new String[]{"", "만","","조"};
        String[] str = d.format(db).split(",");
        String result = "";
        int cnt = 0;
        for(int i=str.length;i>0;i--) {
            if(Integer.parseInt(str[i-1]) != 0) {
                result = String.valueOf(Integer.parseInt(str[i-1])) + unit[cnt] + result;
            }
            cnt++;
        }
        System.out.println(result + "원");
    }

}

 

결과

154조78263만2346원

728x90
반응형
블로그 이미지

nineDeveloper

안녕하세요 현직 개발자 입니다 ~ 빠르게 변화하는 세상에 뒤쳐지지 않도록 우리모두 열심히 공부합시다 ~! 개발공부는 넘나 재미있는 것~!

,