Java Calendar.getDisplayNames(int field, int style, Locale locale)

Syntax

Calendar.getDisplayNames(int field, int style, Locale locale) has the following syntax.

public Map <String , Integer> getDisplayNames(int field,     int style,     Locale locale)

Example

In the following code shows how to use Calendar.getDisplayNames(int field, int style, Locale locale) method.


/*  ww  w. j a v a  2s.  c  o  m*/

import java.util.Calendar;
import java.util.Locale;
import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;

public class Main {

  public static void main(String[] args) {

    Calendar now = Calendar.getInstance();
    Locale locale = Locale.getDefault();

    // call the getdisplaynames method
    Map<String, Integer> representations = now.getDisplayNames(
        Calendar.DAY_OF_WEEK, Calendar.LONG, locale);
    
    NavigableMap<String, Integer> navMap = new TreeMap<String, Integer>(
        representations);

    // print the results
    System.out.printf("Whole list:%n%s%n", navMap);
  }
}

The code above generates the following result.