Enum CountryCode
- java.lang.Object
-
- java.lang.Enum<CountryCode>
-
- com.neovisionaries.i18n.CountryCode
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<CountryCode>
public enum CountryCode extends java.lang.Enum<CountryCode>
ISO 3166-1 country code.Enum names of this enum themselves are represented by ISO 3166-1 alpha-2 code (2-letter upper-case alphabets). There are instance methods to get the country name (
getName()
), the ISO 3166-1 alpha-3 code (getAlpha3()
) and the ISO 3166-1 numeric code (getNumeric()
). In addition, there are static methods to get aCountryCode
instance that corresponds to a given alpha-2/alpha-3/numeric code (getByCode(String)
,getByCode(int)
).// List all the country codes. for (CountryCode code : CountryCode.values()) { // For example, "[US] United States" is printed. System.out.format("[%s] %s\n", code, code.
getName()
); } // Get a CountryCode instance by ISO 3166-1 code. CountryCode code = CountryCode.getByCode
("JP"); // Print all the information. Output will be: // // Country name = Japan // ISO 3166-1 alpha-2 code = JP // ISO 3166-1 alpha-3 code = JPN // ISO 3166-1 numeric code = 392 // Assignment state = OFFICIALLY_ASSIGNED // System.out.println("Country name = " + code.getName()
); System.out.println("ISO 3166-1 alpha-2 code = " + code.getAlpha2()
); System.out.println("ISO 3166-1 alpha-3 code = " + code.getAlpha3()
); System.out.println("ISO 3166-1 numeric code = " + code.getNumeric()
); System.out.println("Assignment state = " + code.getAssignment()
); // Convert to a Locale instance.Locale
locale = code.toLocale()
; // Get a CountryCode by a Locale instance. code = CountryCode.getByLocale
(locale); // Get the currency of the country.Currency
currency = code.getCurrency()
; // Get a list by a regular expression for names. // // The list will contain: // // CountryCode.AE : United Arab Emirates // CountryCode.GB : United Kingdom // CountryCode.TZ : Tanzania, United Republic of // CountryCode.UK : United Kingdom // CountryCode.UM : United States Minor Outlying Islands // CountryCode.US : United States // List<CountryCode> list = CountryCode.findByName
(".*United.*"); // For backward compatibility for older versions than 1.16, some // 4-letter ISO 3166-3 codes are accepted by getByCode(String, boolean) // and its variants. To be concrete: // // ANHH : CountryCode.AN // BUMM : CountryCode.BU // CSXX : CountryCode.CS // NTHH : CountryCode.NT // TPTL : CountryCode.TP // YUCS : CountryCode.YU // ZRCD : CountryCode.ZR // code = CountryCode.getByCode
("ANHH");
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CountryCode.Assignment
Code assignment state in ISO 3166-1.
-
Enum Constant Summary
Enum Constants Enum Constant Description AC
Ascension Island [AC, ASC, -1, Exceptionally reserved]AD
AE
United Arab Emirates [AE, AE, 784, Officially assigned]AF
Afghanistan [AF, AFG, 4, Officially assigned]AG
Antigua and Barbuda [AG, ATG, 28, Officially assigned]AI
AL
AM
AN
Netherlands Antilles [AN, ANT, 530, Traditionally reserved]AO
AQ
Antarctica [AQ, ATA, 10, Officially assigned]AR
AS
American Samoa [AS, ASM, 16, Officially assigned]AT
AU
AW
AX
Åland Islands [AX, ALA, 248, Officially assigned]AZ
Azerbaijan [AZ, AZE, 31, Officially assigned]BA
Bosnia and Herzegovina [BA, BIH, 70, Officially assigned]BB
BD
Bangladesh [BD, BGD, 50, Officially assigned]BE
BF
Burkina Faso [BF, BFA, 854, Officially assigned]BG
BH
BI
BJ
BL
Saint Barthélemy [BL, BLM, 652, Officially assigned]BM
BN
Brunei Darussalam [BN, BRN, 96, Officially assigned]BO
Bolivia, Plurinational State of [BO, BOL, 68, Officially assigned]BQ
Bonaire, Sint Eustatius and Saba [BQ, BES, 535, Officially assigned]BR
BS
BT
BU
BV
Bouvet Island [BV, BVT, 74, Officially assigned]BW
BY
BZ
CA
CC
Cocos (Keeling) Islands [CC, CCK, 166, Officially assigned]CD
Congo, the Democratic Republic of the [CD, COD, 180, Officially assigned]CF
Central African Republic [CF, CAF, 140, Officially assigned]CG
CH
Switzerland [CH, CHE, 756, Officially assigned]CI
Côte d'Ivoire [CI, CIV, 384, Officially assigned]CK
Cook Islands [CK, COK, 184, Officially assigned]CL
CM
CN
CO
CP
Clipperton Island [CP, CPT, -1, Exceptionally reserved]CR
Costa Rica [CR, CRI, 188, Officially assigned]CS
Serbia and Montenegro [CS, SCG, 891, Traditionally reserved]CU
CV
Cape Verde [CV, CPV, 132, Officially assigned]CW
CX
Christmas Island [CX, CXR, 162, Officially assigned]CY
CZ
Czech Republic [CZ, CZE, 203, Officially assigned]DE
DG
Diego Garcia [DG, DGA, -1, Exceptionally reserved]DJ
DK
DM
DO
Dominican Republic [DO, DOM, 214, Officially assigned]DZ
EA
EC
EE
EG
EH
Western Sahara [EH, ESH, 732, Officially assigned]ER
ES
ET
EU
European Union [EU, null, -1, Exceptionally reserved]EZ
FI
FJ
FK
Falkland Islands (Malvinas) [FK, FLK, 238, Officially assigned]FM
Micronesia, Federated States of [FM, FSM, 583, Officially assigned]FO
Faroe Islands [FO, FRO, 234, Officially assigned]FR
FX
France, Metropolitan [FX, FXX, 249, Exceptionally reserved]GA
GB
United Kingdom [GB, GBR, 826, Officially assigned]GD
GE
GF
French Guiana [GF, GUF, 254, Officially assigned]GG
GH
GI
GL
GM
GN
GP
Guadeloupe [GP, GLP, 312, Officially assigned]GQ
Equatorial Guinea [GQ, GNQ, 226, Officially assigned]GR
GS
South Georgia and the South Sandwich Islands [GS, SGS, 239, Officially assigned]GT
GU
GW
Guinea-Bissau [GW, GNB, 624, Officially assigned]GY
HK
HM
Heard Island and McDonald Islands [HM, HMD, 334, Officially assigned]HN
HR
HT
HU
IC
Canary Islands [IC, null, -1, Exceptionally reserved]ID
IE
IL
IM
Isle of Man [IM, IMN, 833, Officially assigned]IN
IO
British Indian Ocean Territory [IO, IOT, 86, Officially assigned]IQ
IR
Iran, Islamic Republic of [IR, IRN, 364, Officially assigned]IS
IT
JE
JM
JO
JP
KE
KG
Kyrgyzstan [KG, KGZ, 417, Officially assigned]KH
KI
KM
KN
Saint Kitts and Nevis [KN, KNA, 659, Officially assigned]KP
Korea, Democratic People's Republic of [KP, PRK, 408, Officially assigned]KR
Korea, Republic of [KR, KOR, 410, Officially assigned]KW
KY
Cayman Islands [KY, CYM, 136, Officially assigned]KZ
Kazakhstan [KZ, KAZ, 398, Officially assigned]LA
Lao People's Democratic Republic [LA, LAO, 418, Officially assigned]LB
LC
Saint Lucia [LC, LCA, 662, Officially assigned]LI
Liechtenstein [LI, LIE, 438, Officially assigned]LK
LR
LS
LT
LU
Luxembourg [LU, LUX, 442, Officially assigned]LV
LY
MA
MC
MD
Moldova, Republic of [MD, MDA, 498, Officially assigned]ME
Montenegro [ME, MNE, 499, Officially assigned]MF
Saint Martin (French part) [MF, MAF, 663, Officially assigned]MG
Madagascar [MG, MDG, 450, Officially assigned]MH
Marshall Islands [MH, MHL, 584, Officially assigned]MK
North Macedonia, Republic of [MK, MKD, 807, Officially assigned]ML
MM
MN
MO
MP
Northern Mariana Islands [MP, MNP, 580, Officially assigned]MQ
Martinique [MQ, MTQ, 474, Officially assigned]MR
Mauritania [MR, MRT, 478, Officially assigned]MS
Montserrat [MS, MSR, 500, Officially assigned]MT
MU
MV
MW
MX
MY
MZ
Mozambique [MZ, MOZ, 508, Officially assigned]NA
NC
New Caledonia [NC, NCL, 540, Officially assigned]NE
NF
Norfolk Island [NF, NFK, 574, Officially assigned]NG
NI
NL
Netherlands [NL, NLD, 528, Officially assigned]NO
NP
NR
NT
Neutral Zone [NT, NTZ, 536, Traditionally reserved]NU
NZ
New Zealand [NZ, NZL, 554, Officially assigned]OM
PA
PE
PF
French Polynesia [PF, PYF, 258, Officially assigned]PG
Papua New Guinea [PG, PNG, 598, Officially assigned]PH
Philippines [PH, PHL, 608, Officially assigned]PK
PL
PM
Saint Pierre and Miquelon [PM, SPM, 666, Officially assigned]PN
PR
Puerto Rico [PR, PRI, 630, Officially assigned]PS
Palestine, State of [PS, PSE, 275, Officially assigned]PT
PW
PY
QA
RE
RO
RS
RU
Russian Federation [RU, RUS, 643, Officially assigned]RW
SA
Saudi Arabia [SA, SAU, 682, Officially assigned]SB
Solomon Islands [SB, SLB, 90, Officially assigned]SC
Seychelles [SC, SYC, 690, Officially assigned]SD
SE
SF
SG
SH
Saint Helena, Ascension and Tristan da Cunha [SH, SHN, 654, Officially assigned]SI
SJ
Svalbard and Jan Mayen [SJ, SJM, 744, Officially assigned]SK
SL
Sierra Leone [SL, SLE, 694, Officially assigned]SM
San Marino [SM, SMR, 674, Officially assigned]SN
SO
SR
SS
South Sudan [SS, SSD, 728, Officially assigned]ST
Sao Tome and Principe [ST, STP, 678, Officially assigned]SU
SV
El Salvador [SV, SLV, 222, Officially assigned]SX
Sint Maarten (Dutch part) [SX, SXM, 534, Officially assigned]SY
Syrian Arab Republic [SY, SYR, 760, Officially assigned]SZ
TA
Tristan da Cunha [TA, TAA, -1, Exceptionally reserved.TC
Turks and Caicos Islands [TC, TCA, 796, Officially assigned]TD
TF
French Southern Territories [TF, ATF, 260, Officially assigned]TG
TH
TJ
Tajikistan [TJ, TJK, 762, Officially assigned]TK
TL
Timor-Leste [TL, TLS, 626, Officially assigned]TM
Turkmenistan [TM, TKM, 795, Officially assigned]TN
TO
TP
East Timor [TP, TMP, 626, Traditionally reserved]TR
TT
Trinidad and Tobago [TT, TTO, 780, Officially assigned]TV
TW
Taiwan, Province of China [TW, TWN, 158, Officially assigned]TZ
Tanzania, United Republic of [TZ, TZA, 834, Officially assigned]UA
UG
UK
United Kingdom [UK, null, 826, Exceptionally reserved]UM
United States Minor Outlying Islands [UM, UMI, 581, Officially assigned]UNDEFINED
Undefined [UNDEFINED, null, -1, User assigned]US
United States [US, USA, 840, Officially assigned]UY
UZ
Uzbekistan [UZ, UZB, 860, Officially assigned]VA
Holy See (Vatican City State) [VA, VAT, 336, Officially assigned]VC
Saint Vincent and the Grenadines [VC, VCT, 670, Officially assigned]VE
Venezuela, Bolivarian Republic of [VE, VEN, 862, Officially assigned]VG
Virgin Islands, British [VG, VGB, 92, Officially assigned]VI
Virgin Islands, U.S. [VI, VIR, 850, Officially assigned]VN
VU
WF
Wallis and Futuna [WF, WLF, 876, Officially assigned]WS
XI
Northern Ireland [XI, XXI, -1, User assigned]XK
Kosovo, Republic of [XK, XXK, -1, User assigned]XU
United Kingdom (excluding Northern Ireland) [XU, XXU, -1, User assigned]YE
YT
YU
Yugoslavia [YU, YUG, 890, Traditionally reserved]ZA
South Africa [ZA, ZAF, 710, Officially assigned]ZM
ZR
ZW
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
alpha3
private static java.util.Map<java.lang.String,CountryCode>
alpha3Map
private static java.util.Map<java.lang.String,CountryCode>
alpha4Map
private CountryCode.Assignment
assignment
private java.lang.String
name
private int
numeric
private static java.util.Map<java.lang.Integer,CountryCode>
numericMap
-
Constructor Summary
Constructors Modifier Constructor Description private
CountryCode(java.lang.String name, java.lang.String alpha3, int numeric, CountryCode.Assignment assignment)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.String
canonicalize(java.lang.String code, boolean caseSensitive)
Canonicalize the given country code.static java.util.List<CountryCode>
findByName(java.lang.String regex)
Get a list ofCountryCode
by a name regular expression.static java.util.List<CountryCode>
findByName(java.util.regex.Pattern pattern)
Get a list ofCountryCode
by a name pattern.java.lang.String
getAlpha2()
Get the ISO 3166-1 alpha-2 code.java.lang.String
getAlpha3()
Get the ISO 3166-1 alpha-3 code.CountryCode.Assignment
getAssignment()
Get the assignment state of this country code in ISO 3166-1.static CountryCode
getByAlpha2Code(java.lang.String code)
Get aCountryCode
that corresponds to the given ISO 3166-1 alpha-2 code.static CountryCode
getByAlpha3Code(java.lang.String code)
Get aCountryCode
that corresponds to the given ISO 3166-1 alpha-3 code.static CountryCode
getByAlpha4Code(java.lang.String code)
Get aCountryCode
that corresponds to the given alpha-4 code.static CountryCode
getByCode(int code)
Get aCountryCode
that corresponds to the given ISO 3166-1 numeric code.static CountryCode
getByCode(java.lang.String code)
static CountryCode
getByCode(java.lang.String code, boolean caseSensitive)
static CountryCode
getByCodeIgnoreCase(java.lang.String code)
static CountryCode
getByLocale(java.util.Locale locale)
Get aCountryCode
that corresponds to the country code of the givenLocale
instance.java.util.Currency
getCurrency()
Get the currency.java.lang.String
getName()
Get the country name.int
getNumeric()
Get the ISO 3166-1 numeric code.java.util.Locale
toLocale()
Convert thisCountryCode
instance to aLocale
instance.static CountryCode
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static CountryCode[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
UNDEFINED
public static final CountryCode UNDEFINED
Undefined [UNDEFINED, null, -1, User assigned]This is not an official ISO 3166-1 code.
- Since:
- 1.14
-
AC
public static final CountryCode AC
Ascension Island [AC, ASC, -1, Exceptionally reserved]
-
AD
public static final CountryCode AD
-
AE
public static final CountryCode AE
United Arab Emirates [AE, AE, 784, Officially assigned]
-
AF
public static final CountryCode AF
Afghanistan [AF, AFG, 4, Officially assigned]
-
AG
public static final CountryCode AG
Antigua and Barbuda [AG, ATG, 28, Officially assigned]
-
AI
public static final CountryCode AI
-
AL
public static final CountryCode AL
-
AM
public static final CountryCode AM
-
AN
public static final CountryCode AN
Netherlands Antilles [AN, ANT, 530, Traditionally reserved]Since version 1.16, the value of alpha-3 code of this entry is
ANT
(notANHH
).
-
AO
public static final CountryCode AO
-
AQ
public static final CountryCode AQ
Antarctica [AQ, ATA, 10, Officially assigned]
-
AR
public static final CountryCode AR
-
AS
public static final CountryCode AS
American Samoa [AS, ASM, 16, Officially assigned]
-
AT
public static final CountryCode AT
-
AU
public static final CountryCode AU
-
AW
public static final CountryCode AW
-
AX
public static final CountryCode AX
Åland Islands [AX, ALA, 248, Officially assigned]The country name was changed from "â„«land Islands" (up to 1.14) to "Ã…land Islands" (since 1.15).
-
AZ
public static final CountryCode AZ
Azerbaijan [AZ, AZE, 31, Officially assigned]
-
BA
public static final CountryCode BA
Bosnia and Herzegovina [BA, BIH, 70, Officially assigned]
-
BB
public static final CountryCode BB
-
BD
public static final CountryCode BD
Bangladesh [BD, BGD, 50, Officially assigned]
-
BE
public static final CountryCode BE
-
BF
public static final CountryCode BF
Burkina Faso [BF, BFA, 854, Officially assigned]
-
BG
public static final CountryCode BG
-
BH
public static final CountryCode BH
-
BI
public static final CountryCode BI
-
BJ
public static final CountryCode BJ
-
BL
public static final CountryCode BL
Saint Barthélemy [BL, BLM, 652, Officially assigned]
-
BM
public static final CountryCode BM
-
BN
public static final CountryCode BN
Brunei Darussalam [BN, BRN, 96, Officially assigned]
-
BO
public static final CountryCode BO
Bolivia, Plurinational State of [BO, BOL, 68, Officially assigned]
-
BQ
public static final CountryCode BQ
Bonaire, Sint Eustatius and Saba [BQ, BES, 535, Officially assigned]
-
BR
public static final CountryCode BR
-
BS
public static final CountryCode BS
-
BT
public static final CountryCode BT
-
BU
public static final CountryCode BU
Burma [BU, BUMM, 104, Officially assigned]Since version 1.16, the value of alpha-3 code of this entry is
BUR
(notBUMM
).- See Also:
MM
-
BV
public static final CountryCode BV
Bouvet Island [BV, BVT, 74, Officially assigned]
-
BW
public static final CountryCode BW
-
BY
public static final CountryCode BY
-
BZ
public static final CountryCode BZ
-
CA
public static final CountryCode CA
-
CC
public static final CountryCode CC
Cocos (Keeling) Islands [CC, CCK, 166, Officially assigned]
-
CD
public static final CountryCode CD
Congo, the Democratic Republic of the [CD, COD, 180, Officially assigned]- See Also:
ZR
-
CF
public static final CountryCode CF
Central African Republic [CF, CAF, 140, Officially assigned]
-
CG
public static final CountryCode CG
-
CH
public static final CountryCode CH
Switzerland [CH, CHE, 756, Officially assigned]
-
CI
public static final CountryCode CI
Côte d'Ivoire [CI, CIV, 384, Officially assigned]
-
CK
public static final CountryCode CK
Cook Islands [CK, COK, 184, Officially assigned]
-
CL
public static final CountryCode CL
-
CM
public static final CountryCode CM
-
CN
public static final CountryCode CN
-
CO
public static final CountryCode CO
-
CP
public static final CountryCode CP
Clipperton Island [CP, CPT, -1, Exceptionally reserved]
-
CR
public static final CountryCode CR
Costa Rica [CR, CRI, 188, Officially assigned]
-
CS
public static final CountryCode CS
Serbia and Montenegro [CS, SCG, 891, Traditionally reserved]Since version 1.16, the value of alpha-3 code of this entry is
SCG
(notCSXX
).
-
CU
public static final CountryCode CU
-
CV
public static final CountryCode CV
Cape Verde [CV, CPV, 132, Officially assigned]
-
CW
public static final CountryCode CW
-
CX
public static final CountryCode CX
Christmas Island [CX, CXR, 162, Officially assigned]
-
CY
public static final CountryCode CY
-
CZ
public static final CountryCode CZ
Czech Republic [CZ, CZE, 203, Officially assigned]
-
DE
public static final CountryCode DE
-
DG
public static final CountryCode DG
Diego Garcia [DG, DGA, -1, Exceptionally reserved]
-
DJ
public static final CountryCode DJ
-
DK
public static final CountryCode DK
-
DM
public static final CountryCode DM
-
DO
public static final CountryCode DO
Dominican Republic [DO, DOM, 214, Officially assigned]
-
DZ
public static final CountryCode DZ
-
EA
public static final CountryCode EA
-
EC
public static final CountryCode EC
-
EE
public static final CountryCode EE
-
EG
public static final CountryCode EG
-
EH
public static final CountryCode EH
Western Sahara [EH, ESH, 732, Officially assigned]
-
ER
public static final CountryCode ER
-
ES
public static final CountryCode ES
-
ET
public static final CountryCode ET
-
EU
public static final CountryCode EU
European Union [EU, null, -1, Exceptionally reserved]
-
EZ
public static final CountryCode EZ
- Since:
- 1.23
-
FI
public static final CountryCode FI
- See Also:
SF
-
FJ
public static final CountryCode FJ
-
FK
public static final CountryCode FK
Falkland Islands (Malvinas) [FK, FLK, 238, Officially assigned]
-
FM
public static final CountryCode FM
Micronesia, Federated States of [FM, FSM, 583, Officially assigned]
-
FO
public static final CountryCode FO
Faroe Islands [FO, FRO, 234, Officially assigned]
-
FR
public static final CountryCode FR
-
FX
public static final CountryCode FX
France, Metropolitan [FX, FXX, 249, Exceptionally reserved]Since version 1.17, the numeric code of this entry is 249.
-
GA
public static final CountryCode GA
-
GB
public static final CountryCode GB
United Kingdom [GB, GBR, 826, Officially assigned]- See Also:
UK
-
GD
public static final CountryCode GD
-
GE
public static final CountryCode GE
-
GF
public static final CountryCode GF
French Guiana [GF, GUF, 254, Officially assigned]
-
GG
public static final CountryCode GG
-
GH
public static final CountryCode GH
-
GI
public static final CountryCode GI
-
GL
public static final CountryCode GL
-
GM
public static final CountryCode GM
-
GN
public static final CountryCode GN
-
GP
public static final CountryCode GP
Guadeloupe [GP, GLP, 312, Officially assigned]
-
GQ
public static final CountryCode GQ
Equatorial Guinea [GQ, GNQ, 226, Officially assigned]
-
GR
public static final CountryCode GR
-
GS
public static final CountryCode GS
South Georgia and the South Sandwich Islands [GS, SGS, 239, Officially assigned]
-
GT
public static final CountryCode GT
-
GU
public static final CountryCode GU
-
GW
public static final CountryCode GW
Guinea-Bissau [GW, GNB, 624, Officially assigned]
-
GY
public static final CountryCode GY
-
HK
public static final CountryCode HK
-
HM
public static final CountryCode HM
Heard Island and McDonald Islands [HM, HMD, 334, Officially assigned]
-
HN
public static final CountryCode HN
-
HR
public static final CountryCode HR
-
HT
public static final CountryCode HT
-
HU
public static final CountryCode HU
-
IC
public static final CountryCode IC
Canary Islands [IC, null, -1, Exceptionally reserved]
-
ID
public static final CountryCode ID
-
IE
public static final CountryCode IE
-
IL
public static final CountryCode IL
-
IM
public static final CountryCode IM
Isle of Man [IM, IMN, 833, Officially assigned]
-
IN
public static final CountryCode IN
-
IO
public static final CountryCode IO
British Indian Ocean Territory [IO, IOT, 86, Officially assigned]
-
IQ
public static final CountryCode IQ
-
IR
public static final CountryCode IR
Iran, Islamic Republic of [IR, IRN, 364, Officially assigned]
-
IS
public static final CountryCode IS
-
IT
public static final CountryCode IT
-
JE
public static final CountryCode JE
-
JM
public static final CountryCode JM
-
JO
public static final CountryCode JO
-
JP
public static final CountryCode JP
-
KE
public static final CountryCode KE
-
KG
public static final CountryCode KG
Kyrgyzstan [KG, KGZ, 417, Officially assigned]
-
KH
public static final CountryCode KH
-
KI
public static final CountryCode KI
-
KM
public static final CountryCode KM
-
KN
public static final CountryCode KN
Saint Kitts and Nevis [KN, KNA, 659, Officially assigned]
-
KP
public static final CountryCode KP
Korea, Democratic People's Republic of [KP, PRK, 408, Officially assigned]
-
KR
public static final CountryCode KR
Korea, Republic of [KR, KOR, 410, Officially assigned]
-
KW
public static final CountryCode KW
-
KY
public static final CountryCode KY
Cayman Islands [KY, CYM, 136, Officially assigned]
-
KZ
public static final CountryCode KZ
Kazakhstan [KZ, KAZ, 398, Officially assigned]
-
LA
public static final CountryCode LA
Lao People's Democratic Republic [LA, LAO, 418, Officially assigned]
-
LB
public static final CountryCode LB
-
LC
public static final CountryCode LC
Saint Lucia [LC, LCA, 662, Officially assigned]
-
LI
public static final CountryCode LI
Liechtenstein [LI, LIE, 438, Officially assigned]
-
LK
public static final CountryCode LK
-
LR
public static final CountryCode LR
-
LS
public static final CountryCode LS
-
LT
public static final CountryCode LT
-
LU
public static final CountryCode LU
Luxembourg [LU, LUX, 442, Officially assigned]
-
LV
public static final CountryCode LV
-
LY
public static final CountryCode LY
-
MA
public static final CountryCode MA
-
MC
public static final CountryCode MC
-
MD
public static final CountryCode MD
Moldova, Republic of [MD, MDA, 498, Officially assigned]
-
ME
public static final CountryCode ME
Montenegro [ME, MNE, 499, Officially assigned]
-
MF
public static final CountryCode MF
Saint Martin (French part) [MF, MAF, 663, Officially assigned]
-
MG
public static final CountryCode MG
Madagascar [MG, MDG, 450, Officially assigned]
-
MH
public static final CountryCode MH
Marshall Islands [MH, MHL, 584, Officially assigned]
-
MK
public static final CountryCode MK
North Macedonia, Republic of [MK, MKD, 807, Officially assigned]
-
ML
public static final CountryCode ML
-
MM
public static final CountryCode MM
- See Also:
BU
-
MN
public static final CountryCode MN
-
MO
public static final CountryCode MO
-
MP
public static final CountryCode MP
Northern Mariana Islands [MP, MNP, 580, Officially assigned]
-
MQ
public static final CountryCode MQ
Martinique [MQ, MTQ, 474, Officially assigned]
-
MR
public static final CountryCode MR
Mauritania [MR, MRT, 478, Officially assigned]
-
MS
public static final CountryCode MS
Montserrat [MS, MSR, 500, Officially assigned]
-
MT
public static final CountryCode MT
-
MU
public static final CountryCode MU
-
MV
public static final CountryCode MV
-
MW
public static final CountryCode MW
-
MX
public static final CountryCode MX
-
MY
public static final CountryCode MY
-
MZ
public static final CountryCode MZ
Mozambique [MZ, MOZ, 508, Officially assigned]
-
NA
public static final CountryCode NA
-
NC
public static final CountryCode NC
New Caledonia [NC, NCL, 540, Officially assigned]
-
NE
public static final CountryCode NE
-
NF
public static final CountryCode NF
Norfolk Island [NF, NFK, 574, Officially assigned]
-
NG
public static final CountryCode NG
-
NI
public static final CountryCode NI
-
NL
public static final CountryCode NL
Netherlands [NL, NLD, 528, Officially assigned]
-
NO
public static final CountryCode NO
-
NP
public static final CountryCode NP
-
NR
public static final CountryCode NR
-
NT
public static final CountryCode NT
Neutral Zone [NT, NTZ, 536, Traditionally reserved]Since version 1.16, the value of alpha-3 code of this entry is
NTZ
(notNTHH
).
-
NU
public static final CountryCode NU
-
NZ
public static final CountryCode NZ
New Zealand [NZ, NZL, 554, Officially assigned]
-
OM
public static final CountryCode OM
-
PA
public static final CountryCode PA
-
PE
public static final CountryCode PE
-
PF
public static final CountryCode PF
French Polynesia [PF, PYF, 258, Officially assigned]
-
PG
public static final CountryCode PG
Papua New Guinea [PG, PNG, 598, Officially assigned]
-
PH
public static final CountryCode PH
Philippines [PH, PHL, 608, Officially assigned]
-
PK
public static final CountryCode PK
-
PL
public static final CountryCode PL
-
PM
public static final CountryCode PM
Saint Pierre and Miquelon [PM, SPM, 666, Officially assigned]
-
PN
public static final CountryCode PN
-
PR
public static final CountryCode PR
Puerto Rico [PR, PRI, 630, Officially assigned]
-
PS
public static final CountryCode PS
Palestine, State of [PS, PSE, 275, Officially assigned]
-
PT
public static final CountryCode PT
-
PW
public static final CountryCode PW
-
PY
public static final CountryCode PY
-
QA
public static final CountryCode QA
-
RE
public static final CountryCode RE
-
RO
public static final CountryCode RO
-
RS
public static final CountryCode RS
-
RU
public static final CountryCode RU
Russian Federation [RU, RUS, 643, Officially assigned]
-
RW
public static final CountryCode RW
-
SA
public static final CountryCode SA
Saudi Arabia [SA, SAU, 682, Officially assigned]
-
SB
public static final CountryCode SB
Solomon Islands [SB, SLB, 90, Officially assigned]
-
SC
public static final CountryCode SC
Seychelles [SC, SYC, 690, Officially assigned]
-
SD
public static final CountryCode SD
-
SE
public static final CountryCode SE
-
SF
public static final CountryCode SF
- See Also:
FI
-
SG
public static final CountryCode SG
-
SH
public static final CountryCode SH
Saint Helena, Ascension and Tristan da Cunha [SH, SHN, 654, Officially assigned]
-
SI
public static final CountryCode SI
-
SJ
public static final CountryCode SJ
Svalbard and Jan Mayen [SJ, SJM, 744, Officially assigned]
-
SK
public static final CountryCode SK
-
SL
public static final CountryCode SL
Sierra Leone [SL, SLE, 694, Officially assigned]
-
SM
public static final CountryCode SM
San Marino [SM, SMR, 674, Officially assigned]
-
SN
public static final CountryCode SN
-
SO
public static final CountryCode SO
-
SR
public static final CountryCode SR
-
SS
public static final CountryCode SS
South Sudan [SS, SSD, 728, Officially assigned]
-
ST
public static final CountryCode ST
Sao Tome and Principe [ST, STP, 678, Officially assigned]
-
SU
public static final CountryCode SU
-
SV
public static final CountryCode SV
El Salvador [SV, SLV, 222, Officially assigned]
-
SX
public static final CountryCode SX
Sint Maarten (Dutch part) [SX, SXM, 534, Officially assigned]
-
SY
public static final CountryCode SY
Syrian Arab Republic [SY, SYR, 760, Officially assigned]
-
SZ
public static final CountryCode SZ
-
TA
public static final CountryCode TA
Tristan da Cunha [TA, TAA, -1, Exceptionally reserved.
-
TC
public static final CountryCode TC
Turks and Caicos Islands [TC, TCA, 796, Officially assigned]
-
TD
public static final CountryCode TD
-
TF
public static final CountryCode TF
French Southern Territories [TF, ATF, 260, Officially assigned]
-
TG
public static final CountryCode TG
-
TH
public static final CountryCode TH
-
TJ
public static final CountryCode TJ
Tajikistan [TJ, TJK, 762, Officially assigned]
-
TK
public static final CountryCode TK
-
TL
public static final CountryCode TL
Timor-Leste [TL, TLS, 626, Officially assigned]- See Also:
TM
-
TM
public static final CountryCode TM
Turkmenistan [TM, TKM, 795, Officially assigned]
-
TN
public static final CountryCode TN
-
TO
public static final CountryCode TO
-
TP
public static final CountryCode TP
East Timor [TP, TMP, 626, Traditionally reserved]Since version 1.16, the value of alpha-3 code of this entry is
TMP
(notTPTL
).Since version 1.17, the numeric code of this entry is 626.
- See Also:
TL
-
TR
public static final CountryCode TR
-
TT
public static final CountryCode TT
Trinidad and Tobago [TT, TTO, 780, Officially assigned]
-
TV
public static final CountryCode TV
-
TW
public static final CountryCode TW
Taiwan, Province of China [TW, TWN, 158, Officially assigned]
-
TZ
public static final CountryCode TZ
Tanzania, United Republic of [TZ, TZA, 834, Officially assigned]
-
UA
public static final CountryCode UA
-
UG
public static final CountryCode UG
-
UK
public static final CountryCode UK
United Kingdom [UK, null, 826, Exceptionally reserved]Since version 1.17, the numeric code of this entry is 826.
- See Also:
GB
-
UM
public static final CountryCode UM
United States Minor Outlying Islands [UM, UMI, 581, Officially assigned]
-
US
public static final CountryCode US
United States [US, USA, 840, Officially assigned]
-
UY
public static final CountryCode UY
-
UZ
public static final CountryCode UZ
Uzbekistan [UZ, UZB, 860, Officially assigned]
-
VA
public static final CountryCode VA
Holy See (Vatican City State) [VA, VAT, 336, Officially assigned]
-
VC
public static final CountryCode VC
Saint Vincent and the Grenadines [VC, VCT, 670, Officially assigned]
-
VE
public static final CountryCode VE
Venezuela, Bolivarian Republic of [VE, VEN, 862, Officially assigned]
-
VG
public static final CountryCode VG
Virgin Islands, British [VG, VGB, 92, Officially assigned]
-
VI
public static final CountryCode VI
Virgin Islands, U.S. [VI, VIR, 850, Officially assigned]
-
VN
public static final CountryCode VN
-
VU
public static final CountryCode VU
-
WF
public static final CountryCode WF
Wallis and Futuna [WF, WLF, 876, Officially assigned]
-
WS
public static final CountryCode WS
-
XI
public static final CountryCode XI
Northern Ireland [XI, XXI, -1, User assigned]- Since:
- 1.28
-
XU
public static final CountryCode XU
United Kingdom (excluding Northern Ireland) [XU, XXU, -1, User assigned]- Since:
- 1.29
-
XK
public static final CountryCode XK
Kosovo, Republic of [XK, XXK, -1, User assigned]
-
YE
public static final CountryCode YE
-
YT
public static final CountryCode YT
-
YU
public static final CountryCode YU
Yugoslavia [YU, YUG, 890, Traditionally reserved]Since version 1.16, the value of alpha-3 code of this entry is
YUG
(notYUCS
).
-
ZA
public static final CountryCode ZA
South Africa [ZA, ZAF, 710, Officially assigned]
-
ZM
public static final CountryCode ZM
-
ZR
public static final CountryCode ZR
Zaire [ZR, ZAR, 180, Traditionally reserved]Since version 1.16, the value of alpha-3 code of this entry is
ZAR
(notZRCD
).Since version 1.17, the numeric code of this entry is 180.
- See Also:
CD
-
ZW
public static final CountryCode ZW
-
-
Field Detail
-
alpha3Map
private static final java.util.Map<java.lang.String,CountryCode> alpha3Map
-
alpha4Map
private static final java.util.Map<java.lang.String,CountryCode> alpha4Map
-
numericMap
private static final java.util.Map<java.lang.Integer,CountryCode> numericMap
-
name
private final java.lang.String name
-
alpha3
private final java.lang.String alpha3
-
numeric
private final int numeric
-
assignment
private final CountryCode.Assignment assignment
-
-
Constructor Detail
-
CountryCode
private CountryCode(java.lang.String name, java.lang.String alpha3, int numeric, CountryCode.Assignment assignment)
-
-
Method Detail
-
values
public static CountryCode[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (CountryCode c : CountryCode.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static CountryCode valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getName
public java.lang.String getName()
Get the country name.- Returns:
- The country name.
-
getAlpha2
public java.lang.String getAlpha2()
Get the ISO 3166-1 alpha-2 code.- Returns:
- The ISO 3166-1 alpha-2 code.
UNDEFINED
returns"UNDEFINED"
which is not an official ISO 3166-1 alpha-2 code.
-
getAlpha3
public java.lang.String getAlpha3()
Get the ISO 3166-1 alpha-3 code.- Returns:
- The ISO 3166-1 alpha-3 code.
Some country codes reserved exceptionally (such as
EU
) returnsnull
.UNDEFINED
returnsnull
, too.
-
getNumeric
public int getNumeric()
Get the ISO 3166-1 numeric code.- Returns:
- The ISO 3166-1 numeric code.
Country codes reserved exceptionally (such as
EU
) returns-1
.UNDEFINED
returns-1
, too.
-
getAssignment
public CountryCode.Assignment getAssignment()
Get the assignment state of this country code in ISO 3166-1.- Returns:
- The assignment state.
- See Also:
- Decoding table of ISO 3166-1 alpha-2 codes
-
toLocale
public java.util.Locale toLocale()
Convert thisCountryCode
instance to aLocale
instance.In most cases, this method creates a new
Locale
instance every time it is called, but someCountryCode
instances return their corresponding entries inLocale
class. For example,CountryCode.CA
always returnsLocale.CANADA
.The table below lists
CountryCode
entries whosetoLocale()
do not create new Locale instances but return entries inLocale
class.CountryCode Locale CountryCode.CA
Locale.CANADA
CountryCode.CN
Locale.CHINA
CountryCode.DE
Locale.GERMANY
CountryCode.FR
Locale.FRANCE
CountryCode.GB
Locale.UK
CountryCode.IT
Locale.ITALY
CountryCode.JP
Locale.JAPAN
CountryCode.KR
Locale.KOREA
CountryCode.TW
Locale.TAIWAN
CountryCode.US
Locale.US
In addition,
toLocale()
ofCountryCode.UNDEFINED
behaves a bit differently. It returnsLocale.ROOT
when it is available (i.e. when the version of Java SE is 1.6 or higher). Otherwise, it returns aLocale
instance whose language and country are empty strings. Even in the latter case, the same instance is returned on every call.- Returns:
- A
Locale
instance that matches thisCountryCode
.
-
getCurrency
public java.util.Currency getCurrency()
Get the currency.This method is an alias of
Currency
.
getInstance
(
toLocale()
)
. The only difference is that this method returnsnull
whenCurrency.getInstance(Locale)
throwsIllegalArgumentException
.This method returns
null
when the territory represented by thisCountryCode
instance does not have a currency.AQ
(Antarctica) is one example.In addition, this method returns
null
also when the ISO 3166 code represented by thisCountryCode
instance is not supported by the implementation ofCurrency.getInstance(Locale)
. At the time of this writing,SS
(South Sudan) is one example.- Returns:
- A
Currency
instance. In some cases, null is returned. - Since:
- 1.4
- See Also:
Currency.getInstance(Locale)
-
getByCode
public static CountryCode getByCode(java.lang.String code)
Get aCountryCode
that corresponds to the given ISO 3166-1 alpha-2 or alpha-3 code.This method calls
getByCode
(code, true)
. Note that the behavior has changed since the version 1.13. In the older versions, this method was an alias ofgetByCode(code, false)
.- Parameters:
code
- An ISO 3166-1 alpha-2 or alpha-3 code. When"UNDEFINED"
is given,CountryCode.UNDEFINED
is returned. In addition, for backward compatibility, some 4-letter ISO 3166-3 codes such as"ANHH"
are accepted.- Returns:
- A
CountryCode
instance, ornull
if not found. - See Also:
getByCode(String, boolean)
-
getByCodeIgnoreCase
public static CountryCode getByCodeIgnoreCase(java.lang.String code)
Get aCountryCode
that corresponds to the given ISO 3166-1 alpha-2 or alpha-3 code.This method calls
getByCode
(code, false)
.- Parameters:
code
- An ISO 3166-1 alpha-2 or alpha-3 code. Or"UNDEFINED"
(case insensitive). In addition, for backward compatibility, some 4-letter ISO 3166-3 codes such as"ANHH"
are accepted.- Returns:
- A
CountryCode
instance, ornull
if not found. - Since:
- 1.13
- See Also:
getByCode(String, boolean)
-
getByCode
public static CountryCode getByCode(java.lang.String code, boolean caseSensitive)
- Parameters:
code
- An ISO 3166-1 alpha-2 or alpha-3 code. Or"UNDEFINED"
(its case sensitivity depends on the value ofcaseSensitive
). In addition, for backward compatibility, some 4-letter ISO 3166-3 codes such as"ANHH"
are accepted.caseSensitive
- Iftrue
, the given code should consist of upper-case letters only. Iffalse
, this method internally canonicalizes the given code byString.toUpperCase()
and then performs search. For example,getByCode("jp", true)
returnsnull
, but on the other hand,getByCode("jp", false)
returnsCountryCode.JP
.- Returns:
- A
CountryCode
instance, ornull
if not found.
-
getByLocale
public static CountryCode getByLocale(java.util.Locale locale)
Get aCountryCode
that corresponds to the country code of the givenLocale
instance.- Parameters:
locale
- ALocale
instance.- Returns:
- A
CountryCode
instance, ornull
if not found. WhengetCountry()
method of the givenLocale
instance returnsnull
or an empty string,CountryCode.UNDEFINED
is returned. - See Also:
Locale.getCountry()
-
canonicalize
static java.lang.String canonicalize(java.lang.String code, boolean caseSensitive)
Canonicalize the given country code.- Parameters:
code
- ISO 3166-1 alpha-2 or alpha-3 country code.caseSensitive
-true
if the code should be handled case-sensitively.- Returns:
- If
code
isnull
or an empty string,null
is returned. Otherwise, ifcaseSensitive
istrue
,code
is returned as is. Otherwise,code.toUpperCase()
is returned.
-
getByAlpha2Code
public static CountryCode getByAlpha2Code(java.lang.String code)
Get aCountryCode
that corresponds to the given ISO 3166-1 alpha-2 code.- Parameters:
code
- An ISO 3166-1 alpha-2 code.- Returns:
- A
CountryCode
instance, ornull
if not found. - Since:
- 1.23
-
getByAlpha3Code
public static CountryCode getByAlpha3Code(java.lang.String code)
Get aCountryCode
that corresponds to the given ISO 3166-1 alpha-3 code.- Parameters:
code
- An ISO 3166-1 alpha-3 code.- Returns:
- A
CountryCode
instance, ornull
if not found. - Since:
- 1.23
-
getByAlpha4Code
public static CountryCode getByAlpha4Code(java.lang.String code)
Get aCountryCode
that corresponds to the given alpha-4 code.Recognized alpha-4 codes are listed in the table below.
Alpha-4 Code CountryCode
ANHH
AN
BUMM
BU
CSXX
CS
NTHH
NT
TPTL
TP
YUCS
YU
ZRCD
ZR
- Parameters:
code
- Alpha-4 code.- Returns:
- A
CountryCode
instance, ornull
if not found. - Since:
- 1.23
-
getByCode
public static CountryCode getByCode(int code)
Get aCountryCode
that corresponds to the given ISO 3166-1 numeric code.Note that there are some pairs each of which shares the same numeric code. The following table shows such pairs and which
CountryCode
instance is returned from this method.
Shared Numeric Code Alpha-3 Codes Returned Alpha-3 Code 104 BU
MM
MM
180 CD
ZR
CD
246 FI
SF
FI
826 GB
UK
GB
626 TL
TP
TL
- Parameters:
code
- An ISO 3166-1 numeric code.- Returns:
- A
CountryCode
instance, ornull
if not found. If 0 or a negative value is given,null
is returned.
-
findByName
public static java.util.List<CountryCode> findByName(java.lang.String regex)
Get a list ofCountryCode
by a name regular expression.This method is almost equivalent to
findByName
(Pattern.compile(regex))
.- Parameters:
regex
- Regular expression for names.- Returns:
- List of
CountryCode
. If nothing has matched, an empty list is returned. - Throws:
java.lang.IllegalArgumentException
-regex
isnull
.java.util.regex.PatternSyntaxException
-regex
failed to be compiled.- Since:
- 1.11
-
findByName
public static java.util.List<CountryCode> findByName(java.util.regex.Pattern pattern)
Get a list ofCountryCode
by a name pattern.For example, the list obtained by the code snippet below:
Pattern pattern = Pattern.compile(".*United.*"); List<CountryCode> list = CountryCode.findByName(pattern);
contains 6
CountryCode
s as listed below.- Parameters:
pattern
- Pattern to match names.- Returns:
- List of
CountryCode
. If nothing has matched, an empty list is returned. - Throws:
java.lang.IllegalArgumentException
-pattern
isnull
.- Since:
- 1.11
-
-