// Create a locale for the French language in France.
Locale localeFR = new Locale("fr", "FR");
System.out.println("
Display Name: " +
localeFR.getDisplayName());
System.out.println("Country: " + localeFR.getCountry());
System.out.println("Language: " + localeFR.getLanguage());
// Display the English-US locale in French
System.out.println("
en Display Name in French: " +
localeEN.getDisplayName(localeFR));
}
}
Display Name: English (United States)
Country: US
Language: en
Display Name: French (France)
Country: FR
Language: fr
en Display Name in French: anglais (états-Unis)
public static void main(String[] args) {
// Get the current system date and time.
Date date = new Date();
// Get a France locale using a Locale constant.
Locale localeFR = Locale.FRANCE;
// Create an English/US locale using the constructor.
Locale localeEN = new Locale("en", "US" );
// Get a date time formatter for display in France.
DateFormat fullDateFormatFR =
DateFormat.getDateTimeInstance(
DateFormat.FULL,
DateFormat.FULL,
localeFR);
// Get a date time formatter for display in the U.S.
DateFormat fullDateFormatEN =
DateFormat.getDateTimeInstance(
DateFormat.FULL,
DateFormat.FULL,
localeEN);