When does Local.getCountry() return a UN M.49 3-digit code instead of an ISO 3166 2-letter code?

IIIIIIIIIIIIIIIIIIIIII :

The description of Local.getCountry() says:

Returns the country/region code for this locale, which should either be the empty string, an uppercase ISO 3166 2-letter code, or a UN M.49 3-digit code.

I wonder when is an ISO 3166 2-letter code returned and when a UN M.49 3-digit code ?

Example:

Locale locale = new Locale("de", "AT");
Log.i(TAG, "country code: " + locale.getCountry()); //returns "AT" which is an ISO 3166 2-letter code
Meiswjn :

The return type depends on the country of the created Locale, thus it depends on how the Locale is created. The IANA specifies the country / region codes and supports UN M.49 and ISO 3166 2.

Locale.getCountry() returns the code specified by the IANA List, which is either ISO or UN. Search for "Type: region":

Example UN M.49:

Type: region
Subtag: 053
Description: Australia and New Zealand
Added: 2005-10-16
%%

Example Iso 3166 2:

Type: region
Subtag: VA
Description: Holy See (Vatican City State)
Added: 2005-10-16
%%

Source: https://developer.android.com/reference/java/util/Locale

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=125119&siteId=1