当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java NumberFormat getAvailableLocales()用法及代码示例


getAvailableLocales()方法是java.text.NumberFormat的内置方法,返回本地化NumberFormat实例可用的语言环境数组。因此,所有返回的值都表示Java运行时支持的本地。

用法

public static Locale[] getAvailableLocales()

参数:该函数不接受单个参数。


返回值:该函数返回一个语言环境数组,其本地化的NumberFormat实例可用

下面是上述函数的实现:

示例1:

// Java program to implement 
// the above function 
  
import java.text.NumberFormat; 
import java.util.Locale; 
  
public class Main { 
    public static void main(String[] args) 
        throws Exception 
    { 
  
        // Get all the available country names 
        Locale[] arr 
            = NumberFormat 
                  .getAvailableLocales(); 
  
        // Iterate and print 
        for (Locale it : arr) { 
            System.out.println( 
                it.getDisplayCountry() 
                + " "); 
        } 
    } 
}
输出:
United Arab Emirates 
Jordan 
Syria 
Croatia 
Belgium 
Panama 
Venezuela 
Malta 
 
Taiwan 
 
 
 
 
Denmark 
Puerto Rico 
Vietnam 
United States 
Montenegro 
Sweden 
Singapore 
Bolivia 
Bahrain 
 
Saudi Arabia 
 
Yemen 
India 
 
Malta 
Finland 
 
 
Bosnia and Herzegovina 
 
 
Ukraine 
Switzerland 
 
 
Argentina 
Egypt 
Japan 
El Salvador 
Brazil 
 
Czech Republic 
 
Iceland 
Spain 
Poland 
 
Serbia and Montenegro 
 
Malaysia 
 
Spain 
Bulgaria 
Colombia 
 
 
 
Bosnia and Herzegovina 
Paraguay 
 
 
Ecuador 
United States 
Sudan 
 
Romania 
Philippines 
 
Tunisia 
Montenegro 
Guatemala 
Cyprus 
South Korea 
 
Mexico 
Russia 
Honduras 
Norway 
Hong Kong 
Hungary 
Thailand 
Iraq 
Chile 
Morocco 
 
Ireland 
 
Turkey 
Qatar 
Estonia 
 
Portugal 
Luxembourg 
Oman 
 
Albania 
Dominican Republic 
Cuba 
 
 
New Zealand 
Serbia 
Switzerland 
Uruguay 
 
Greece 
Israel 
South Africa 
Thailand 
 
France 
Austria 
 
Norway 
Australia 
 
Canada 
Latvia 
Netherlands 
Luxembourg 
Costa Rica 
Kuwait 
Libya 
 
Switzerland 
 
 
Germany 
Algeria 
Slovakia 
Italy 
Lithuania 
Ireland 
Singapore 
Canada 
 
Belgium 
 
 
China 
Japan 
Greece 
Serbia 
 
India 
Lebanon 
Nicaragua 
 
Belarus 
Macedonia 
Slovenia 
Peru 
Indonesia 
United Kingdom

参考: https://docs.oracle.com/javase/10/docs/api/java/text/NumberFormat.html#getAvailableLocales()



相关用法


注:本文由纯净天空筛选整理自gopaldave大神的英文原创作品 NumberFormat getAvailableLocales() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。