Java Currency getDisplayName() 方法

2024年11月8日 | 阅读 3 分钟

getDisplayName 方法有两种类型。

Java Currency getDisplayName() 方法

getDisplayName()Java Currency 类 的方法,用于获取调用货币的默认区域设置名称。

语法

以下是 getDisplayName() 方法的声明

参数

数据类型参数描述
不适用不适用此方法不接受任何参数。

返回值

getDisplayName() 方法用于获取调用货币的默认区域设置名称。

异常

不适用

兼容版本

Java 1.7 及以上版本

示例 1

输出

INR is: Indian Rupee

示例 2

输出

Currency: USD
Display name: US Dollar
Currency: CNY
Display name: Chinese Yuan

示例 3

输出

Name of given Currency is: Euro

示例 4

输出

Enter the Currency: INR
Currency name is: Indian Rupee

Java Currency getDisplayName(Locale locale) 方法

getDisplayName(Locale locale)Java Currency 类 的方法,用于获取调用货币的指定区域设置名称。

语法

以下是 getDisplayName(Locale locale) 方法的声明

参数

数据类型参数描述
不适用localelocale 是需要给定货币的显示名称。

返回值

getDisplayName(Locale locale) 方法返回调用货币的指定区域设置名称。

异常

NullPointerException - 如果 locale 为 Null。

兼容版本

Java 1.7 及以上版本。

示例 1

输出

US Dollar

示例 2

输出

Currency: CNY
French display name: yuan renminbi chinois
Korean display name: 중국 위안 인민폐

示例 3

输出

Indian Rupee
rupia india 
Indian Rupee

示例 4

输出

Enter the Locale: IT
Enter the Currency: INR
Default locale is: Indian Rupee
Specified locale is: Rupia Indiana

Enter the locale: EN
Enter the Currency: USD
Default locale is: US Dollar
Specified locale is: US Dollar