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()
相關用法
- Java Calendar getAvailableLocales()用法及代碼示例
- Java BreakIterator getAvailableLocales()用法及代碼示例
- Java DateFormat getAvailableLocales()用法及代碼示例
- Java Locale getAvailableLocales()用法及代碼示例
- Java DecimalFormatSymbols getAvailableLocales()用法及代碼示例
- Java DateFormatSymbols getAvailableLocales()用法及代碼示例
- Java NumberFormat getCurrencyInstance()用法及代碼示例
- Java NumberFormat getIntegerInstance()用法及代碼示例
- Java NumberFormat getInstance()用法及代碼示例
- Java NumberFormat getMaximumFractionDigits()用法及代碼示例
- Java NumberFormat getPercentInstance()用法及代碼示例
- Java NumberFormat getNumberInstance()用法及代碼示例
- Java NumberFormat setMinimumFractionDigits()用法及代碼示例
- Java NumberFormat setGroupingUsed()用法及代碼示例
- Java NumberFormat setMaximumIntegerDigits()用法及代碼示例
注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 NumberFormat getAvailableLocales() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。