Calendar getDisplayName() Method in Java with Examples
The getDisplayName(int cal_field, int cal_style, Locale local) method of Calendar class is used to return the string representation of a calendar field(int cal_field) value in the given style(int cal_style) and locale(int local).
public String getDisplayName(int cal_field, int cal_style, Locale local)
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 getDisplayName() Method of Calendar class:
First object is : turkish_TURKEY Second object is : english_UK Name of the first object: turkish (TURKEY) Name of the second object: english (UK)
First object is : russian_RUSSIA Second object is : german_GERMANY Name of the first object: russian (RUSSIA) Name of the second object: german (GERMANY)