Java DecimalFormatSymbols getCurrency()方法及示例

来源:这里教程网 时间:2026-02-17 20:46:11 作者:

Java DecimalFormatSymbols getCurrency()方法及示例

Java中 java.text .DecimalFormatSymbols类getCurrency() 方法是用来获取该DecimalFormatSymbols的Locale的货币。该方法返回货币。

语法。

public char getCurrency()

参数。此方法不接受任何参数。

返回值。该方法返回带有Locale的DecimalFormatSymbols的货币。

异常。此方法不抛出任何异常。

程序。

// Java program to demonstrate// the above method  import java.text.*;import java.util.*;  public class DecimalFormatSymbolsDemo {    public static void main(String[] args)    {          DecimalFormatSymbols dfs            = new DecimalFormatSymbols();          System.out.println("Current currency: "                           + dfs.getCurrency());    }}

输出:

Current currency: USD

参考资料: https://docs.oracle.com/javase/9/docs/api/java/text/DecimalFormatSymbols.html#getCurrency-

相关推荐