Calendar getDisplayNames() Method in Java with Examples
The getDisplayNames(int cal_field, int cal_style, Locale local) method of Calendar class is used to return a map containing all the names of the calendar field(int cal_field) in the given style(int cal_style) and locale(Locale local) and their corresponding field values.
getDisplayNames(int field, int style, Locale locale)
Parameters: The method takes three parameters:
- cal_field: This is of integer type and refers to the field of the calendar on which the operation is to be performed.
- cal_style: This is of integer type and refers to the style that is supposed to be applied to the string representation.
- local: This is of Locale object type and refers to the locale representing the string.
Return Value: The method either returns the string representation of the given field in the form of the passing style else null if no string representation is available.
Below programs illustrate the working of getDisplayNames() Method of Calendar class:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.