TimeZone getDisplayName(boolean, int) Method in Java with Examples
The getDisplayName(boolean daylight, int style) method of TimeZone class in Java is used to get a particular name of this TimeZone that is easily understood by the user in the specified locale as passed by the user. The name is appropriate for presentation and display purpose.
public final String getDisplayName(boolean daylight, int style)
Parameters: The method takes two parameters:
- daylight: This is of boolean type and specifies if the value is true then it returns the daylight savings name else false.
- style: This is either LONG or SHORT and refers to the style of display
Return Value: The method returns the display name of the TimeZone in the specified locale that is readable to the user.
Below programs illustrate the working of getDisplayName() Method of TimeZone:
The Display name for the locale is: UTC
The Display name for the locale is: Greenwich Mean Time