Java Reference
In-Depth Information
date and time formats. The example code from the
org.java8recipes.chapter12.recipe12_3.Recipe12_3 class demon-
strates this more complex usage:
public class Recipe12_3 {
private static final Date NOW = new Date();
public void run() {
// Set ALL locales to fr-FR
Locale.setDefault(Locale.FRANCE);
demoDefaultLocaleSettings();
// System default is still fr-FR
// DISPLAY default is es-MX
// FORMAT default is en-US
Locale.setDefault(Locale.Category.DISPLAY,
Locale.forLanguageTag("es-MX"));
Locale.setDefault(Locale.Category.FORMAT,
Locale.US);
demoDefaultLocaleSettings();
// System default is still fr-FR
// DISPLAY default is en-US
// FORMAT default is es-MX
Locale.setDefault(Locale.Category.DISPLAY,
Locale.US);
Locale.setDefault(Locale.Category.FORMAT,
Locale.forLanguageTag("es-MX"));
demoDefaultLocaleSettings();
// System default is Locale.US
// Resets both DISPLAY and FORMAT locales to
en-US as well.
Locale.setDefault(Locale.US);
demoDefaultLocaleSettings();
}
Search WWH ::




Custom Search