Java TimeZone - getDisplayName() Method
The java.util.TimeZone.getDisplayName() method returns a long standard time name of this TimeZone suitable for presentation to the user in the default locale.
Syntax
public final String getDisplayName()
Parameters
No parameter is required.
Return Value
Returns the human-readable name of this time zone in the default locale.
Exception
NA
Example:
In the example below, the java.util.TimeZone.getDisplayName() method is used to get a name of the given time zone.
import java.util.*; public class MyClass { public static void main(String[] args) { //creating a TimeZone object TimeZone tz = TimeZone.getDefault(); //get the display name of the TimeZone object Object tzname = tz.getDisplayName(); //printing the display name System.out.println("Display name is: " + tzname); } }
The output of the above code will be:
Display name is: Coordinated Universal Time
❮ Java.util - TimeZone