Displaying Calendar Names : New Locales « JDK 6 « Java






Displaying Calendar Names

 

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);
  }
}

        








Related examples in the same category

1.New locales in Java 6
2.Locale Sensitive Services SPI
3.Japanese Imperial Calendar