// Create a locale for the French language in France. Locale localeFR = new Locale("fr", "FR"); System.out.println("/nDisplay 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("/nen 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)
表 B import java.util.Locale; import java.util.Date; import java.text.DateFormat;
public class DateExample7 {
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);