Mega Code Archive

 
Categories / Java Tutorial / Internationalization
 

Displaying Calendar Names

MyResources.properties file okKey = OK cancelKey = Cancel submitKey = Submit The MyResources_de.properties file cancelKey = Abbrechen import java.util.Calendar; import java.util.Locale; import java.util.Map; public class DisplayNames {   public static void main(String args[]) {     Calendar now = Calendar.getInstance();    // Locale locale = Locale.getDefault();      Locale locale = Locale.ITALIAN;     Map<String, Integer> names = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale);     System.out.println(names);     String name = now.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, locale);     System.out.printf("Today is a %s.%n", name);   } }