Java中如何获得货币符号?

package org.nhooo.example.util;

import java.util.Currency;

import java.util.Locale;

public class CurrencySymbol {

    public static void main(String[] args) {

        Currency currency = Currency.getInstance(Locale.JAPAN);

        System.out.println("Japan = " + currency.getSymbol());

        currency = Currency.getInstance(Locale.UK);

        System.out.println("UK = " + currency.getSymbol());

        currency = Currency.getInstance(Locale.US);

        System.out.println("US = " + currency.getSymbol());

        currency = Currency.getInstance(new Locale("in", "ID"));

        System.out.println("Indonesia = " + currency.getSymbol());

    }

}

上面的代码片段的结果:

Japan = JPY

UK = GBP

US = $

Indonesia = IDR

                       

以上是 Java中如何获得货币符号? 的全部内容, 来源链接: utcz.com/z/334627.html

回到顶部