Last active
December 23, 2015 12:39
-
-
Save rodolfo42/6637163 to your computer and use it in GitHub Desktop.
List all available locales in the current system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.*; | |
import java.util.*; | |
public class LocaleList { | |
static public void main(String[] args) { | |
printCurrentLocale(); | |
Locale list[] = SimpleDateFormat.getAvailableLocales(); | |
Set<String> set = new HashSet<String>(); | |
for (int i = 0; i < list.length; i++) { | |
set.add(list[i].getDisplayName() + "\t\t\t:\t" + list[i].toString()); | |
} | |
Iterator it = set.iterator(); | |
while (it.hasNext()) { | |
System.out.println(it.next()); | |
} | |
} | |
static void printCurrentLocale() { | |
System.out.println("Current locale "); | |
Locale current = Locale.getDefault(); | |
System.out.println("user.language: " + current.getLanguage()); | |
System.out.println("user.country: " + current.getCountry()); | |
System.out.println("user.variant: " + current.getVariant()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment