Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get country name from country code

Tags:

android

locale

I'd need to get the full country name from the country code. For example for Netherlands, I'd need the Netherlands from the country code NL.

I thought I could do that with Locale like:

Locale loc = new Locale("NL"); loc.getCountry(); 

but loc.getCountry(); is empty.

Any idea about how to do this, please? Thanks in advance!

like image 657
noloman Avatar asked Jan 11 '13 10:01

noloman


People also ask

What is the 3 digit country code for USA?

Member countries of the North American Numbering Plan (NANP) are assigned three-digit area codes under the common country prefix 1, shown in the format +1 XXX. +1 – United States, including United States territories: +1 340 – United States Virgin Islands.

How do I know what country a phone number is from?

The first method is using a free online tool called PhoneNum On the front page, you will find a text box into which you can enter the phone number whose origin you wish to determine. A bunch of information will be displayed to you, amongst which will be the country of origin of the phone number.


2 Answers

try like this

Locale loc = new Locale("","NL"); loc.getDisplayCountry(); 

Hope this will help out.

like image 89
Rahul Baradia Avatar answered Sep 24 '22 12:09

Rahul Baradia


This should work:

Locale l = new Locale("", "NL"); String country = l.getDisplayCountry(); 

The first parameter of Locale is the language, which is not useful in your case.

like image 42
assylias Avatar answered Sep 22 '22 12:09

assylias