ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • apex 숫자 원화 표시하는 방법 - ( apex How to display numbers ₩0,000,000 )
    Apex 2024. 4. 5. 16:00

     

    1. setScale(0).format();

    • 숫자 -> 원화표시
    • 10000000 -> ₩ 10,000,000
     
    Decimal numberA = 10000000;
    String stringA = '₩' + numberA.setScale(0).format();
     

    2. Decimal.valueOf([원화형식StringValue].replaceAll(...));

    • 원화 -> 숫자표시
    • ₩ 10,000,000 -> 10000000
     
    String stringA = '₩10,000,000';
    Decimal numberA = Decimal.valueOf(stringA.replaceAll('[^0-9]', ''));
     

     

    3. 예시 코드

    • 원화표시된 기존 금액 ₩ 10,000,000에
    • 청구금액(BillingAmount__c)을 더하여
    • 원화형식으로 표시하기
     
    String   billingAmount  = '₩10,000,000';                                                                //원화표시된 기존 금액
     
    //청구 list 반복
    for(Billing__c bill : billings){
     
      Decimal numberA = Decimal.valueOf( billingAmount.replaceAll('[^0-9]', ''));     //원화표시된 기존 금액 파싱
                   
      Decimal numberB = numberA + bill.BillingAmount__c;                                       //기존 금액 + 청구금액
                   
      String stringA = '₩' + numberB.setScale(0).format();                                          // 해당 금액 원화 표시
                   
      billingAmount = StringA ;                                                                                      // 기존 금액 변경
    }
     

     

     

Designed by Tistory.