java中中国货币符号怎么打_如何在Java中找到货币子单位(又称小单位)符号?

该博客展示了如何在Java中使用DecimalFormat和NumberFormat进行自定义货币格式化,并根据不同的Locale显示货币。示例代码演示了如何为法国、德国、加拿大、塞尔维亚和印度设置货币格式,并打印相应的货币符号。
摘要由CSDN通过智能技术生成

我想建议这种情况使用自定义的定制货币格式。使用DecimalFormat或NumberFormat的java.text。* package。

有很多例子。

public class CurrencyFormatExample {

public void currencyFormat(Locale currentLocale) {

Double currency = new Double(9843.21);

NumberFormat currencyFormatter;

String currencyOut;

currencyFormatter = NumberFormat.getCurrencyInstance(currentLocale);

currencyOut = currencyFormatter.format(currency);

System.out.println(currencyOut + " " + currentLocale.toString());

}

public static void main(String args[]) {

Locale[] locales = new Locale[]{new Locale("fr", "FR"),

new Locale("de", "DE"), new Locale("ca", "CA"),

new Locale("rs", "RS"),new Locale("en", "IN")

};

CurrencyFormatExample[] formate = new CurrencyFormatExample[locales.length];

for (int i = 0; i < locales.length; i++) {

formate[i].currencyFormat(locales[i]);

}

}

}

输出:

9Â 843,21 â?¬ fr_FR

9.843,21 â?¬ de_DE

CAD 9.843,21 ca_CA

RSD 9,843.21 rs_RS

Rs.9,843.21 en_IN

次要货币更新

Locale locale = Locale.UK;

Currency curr = Currency.getInstance(locale);

// get and print the symbol of the currency

String symbol = curr.getSymbol(locale);

System.out.println("Symbol is = " + symbol);

输出:

Symbol is = £

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值