Java Reference
In-Depth Information
public void demoDefaultLocaleSettings() {
DateFormat df =
DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.SHORT);
ResourceBundle resource =
ResourceBundle.getBundle("SimpleResources",
Locale.getDefault(Locale.Category.DISPLAY));
String greeting
= resource.getString("GOOD_MORNING");
String date = df.format(NOW);
System.out.printf("DEFAULT LOCALE: %s\n",
Locale.getDefault());
System.out.printf("DISPLAY LOCALE: %s\n",
Locale.getDefault(Locale.Category.DISPLAY));
System.out.printf("FORMAT LOCALE: %s\n",
Locale.getDefault(Locale.Category.FORMAT));
System.out.printf("%s, %s\n\n", greeting, date );
}
public static void main(String[] args) {
Recipe12_3 app = new Recipe12_3();
app.run();
}
}
This code produces the following output:
DEFAULT LOCALE: fr_FR
DISPLAY LOCALE: fr_FR
FORMAT LOCALE: fr_FR
Bonjour!, 19/09/11 20:31
DEFAULT LOCALE: fr_FR
DISPLAY LOCALE: es_MX
FORMAT LOCALE: en_US
¡Buenos días!, 9/19/11 8:31 PM
DEFAULT LOCALE: fr_FR
Search WWH ::




Custom Search