Currency code to currency symbol mapping

前端 未结 6 1933
太阳男子
太阳男子 2021-02-07 09:46

Good day, in database there is table with houses for sale records. For each house record there is currency code (in ISO 4217 format) field. Is it possibly to somehow get currenc

6条回答
  •  离开以前
    2021-02-07 10:15

    You can use Currency class and DecimalFormat class for achieve your requirement. In following example, # represents number and ¤ represents currency symbol, you can find relevant format parameters in java API doc for DecimalFormat class.

            Currency currency = Currency.getInstance("USD");
    
            DecimalFormat decimalFormat = new DecimalFormat("#¤");
            decimalFormat.setCurrency(currency);
            System.out.println(decimalFormat.format(234));
    

提交回复
热议问题