Java Utility Library

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 specified locale.

Syntax

public final String getDisplayName(Locale locale)

Parameters

locale Specify the locale in which to supply the display name.

Return Value

Returns the human-readable name of this time zone in the given 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 in specified locale.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a TimeZone object
    TimeZone tz = TimeZone.getDefault();

    //creating a locale
    Locale loc = Locale.GERMANY;

    //get the display name of the TimeZone
    //object in French locale
    Object tzname = tz.getDisplayName(loc);

    //printing the display name
    System.out.println("Display name is: " + tzname);
  }
}

The output of the above code will be:

Display name is: Koordinierte Weltzeit

❮ Java.util - TimeZone