Skip to content

Instantly share code, notes, and snippets.

@rodolfo42
Last active December 23, 2015 12:39
Show Gist options
  • Save rodolfo42/6637163 to your computer and use it in GitHub Desktop.
Save rodolfo42/6637163 to your computer and use it in GitHub Desktop.
List all available locales in the current system
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