Java DecimalFormatSymbols getCurrency()方法及示例

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-

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程