Java.util.Locale.getAvailableLocales() Method

Advertisements


Description

The java.util.Locale.getAvailableLocales() method returns an array of all installed locales. The returned array represents the union of locales supported by the Java runtime environment and by installed LocaleServiceProvider implementations. It must contain at least a Locale instance equal to Locale.US.

Declaration

Following is the declaration for java.util.Locale.getAvailableLocales() method

public static Locale[] getAvailableLocales()

Parameters

  • NA

Return Value

This method returns an array of installed locales.

Exception

  • NA

Example

The following example shows the usage of java.util.Locale.getAvailableLocales() method.

package com.tutorialspoint;

import java.util.*;

public class LocaleDemo {

   public static void main(String[] args) {

      // create a new array and get all installed locales
      Locale[] locales = Locale.getAvailableLocales();

      // print locales
      System.out.println("Installed locales are:");
      for (int i = 0; i < locales.length; i++) {
         System.out.println(i + ":" + locales[i]);
      }
   }
}

Let us compile and run the above program, this will produce the following result:

Installed locales are:
0:ja_JP
1:es_PE
2:en
3:ja_JP_JP
4:es_PA
5:sr_BA
6:mk
7:es_GT
8:ar_AE
9:no_NO
10:sq_AL
11:bg
12:ar_IQ
13:ar_YE
14:hu
15:pt_PT
16:el_CY
17:ar_QA
18:mk_MK
19:sv
20:de_CH
21:en_US
22:fi_FI
23:is
24:cs
25:en_MT
26:sl_SI
27:sk_SK
28:it
29:tr_TR
30:zh
31:th
32:ar_SA
33:no
34:en_GB
35:sr_CS
36:lt
37:ro
38:en_NZ
39:no_NO_NY
40:lt_LT
41:es_NI
42:nl
43:ga_IE
44:fr_BE
45:es_ES
46:ar_LB
47:ko
48:fr_CA
49:et_EE
50:ar_KW
51:sr_RS
52:es_US
53:es_MX
54:ar_SD
55:in_ID
56:ru
57:lv
58:es_UY
59:lv_LV
60:iw
61:pt_BR
62:ar_SY
63:hr
64:et
65:es_DO
66:fr_CH
67:hi_IN
68:es_VE
69:ar_BH
70:en_PH
71:ar_TN
72:fi
73:de_AT
74:es
75:nl_NL
76:es_EC
77:zh_TW
78:ar_JO
79:be
80:is_IS
81:es_CO
82:es_CR
83:es_CL
84:ar_EG
85:en_ZA
86:th_TH
87:el_GR
88:it_IT
89:ca
90:hu_HU
91:fr
92:en_IE
93:uk_UA
94:pl_PL
95:fr_LU
96:nl_BE
97:en_IN
98:ca_ES
99:ar_MA
100:es_BO
101:en_AU
102:sr
103:zh_SG
104:pt
105:uk
106:es_SV
107:ru_RU
108:ko_KR
109:vi
110:ar_DZ
111:vi_VN
112:sr_ME
113:sq
114:ar_LY
115:ar
116:zh_CN
117:be_BY
118:zh_HK
119:ja
120:iw_IL
121:bg_BG
122:in
123:mt_MT
124:es_PY
125:sl
126:fr_FR
127:cs_CZ
128:it_CH
129:ro_RO
130:es_PR
131:en_CA
132:de_DE
133:ga
134:de_LU
135:de
136:es_AR
137:sk
138:ms_MY
139:hr_HR
140:en_SG
141:da
142:mt
143:pl
144:ar_OM
145:tr
146:th_TH_TH
147:el
148:ms
149:sv_SE
150:da_DK
151:es_HN



Advertisements
Advertisements