Sunday, December 7, 2025
HomeLanguagesJavaTimeZone getDisplayName(Locale locale) Method in Java with Examples

TimeZone getDisplayName(Locale locale) Method in Java with Examples

The getDisplayName(Locale locale_time) 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.

Syntax:

public final String getDisplayName(Locale locale_time)

Parameters: The method takes one parameter locale_time of Locale object type and refers to the locale into which the display name is to be supplied.

Return Value: The method returns the display name of the TimeZone in the specified locale.

Below programs illustrate the working of getDisplayName() Method of TimeZone:
Example 1:




// Java code to illustrate getDisplayName()
  
import java.util.*;
  
public class TimeZone_Demo {
    public static void main(String args[])
    {
  
        // Creating a time zone object
        TimeZone timezone
            = TimeZone
                  .getTimeZone(
                      "Asia/India");
  
        // Creating the locale
        Locale locale
            = new Locale("ENGLISH",
                         "USA");
  
        // Getting a display name for specified locale
        String display_name
            = timezone
                  .getDisplayName(locale);
  
        // Display name
        System.out.println("The Display name"
                           + " for the locale is: "
                           + display_name);
    }
}


Output:

The Display name for the locale is: Greenwich Mean Time

Example 2:




// Java code to illustrate getDisplayName()
  
import java.util.*;
  
public class TimeZone_Demo {
    public static void main(String args[])
    {
  
        // Creating a time zone object
        TimeZone timezone
            = TimeZone
                  .getTimeZone("Australia/Sydney");
  
        // Creating the locale
        Locale locale = new Locale("ENGLISH",
                                   "Australia");
  
        // Getting a display name
        // for specified locale
        String display_name
            = timezone
                  .getDisplayName(locale);
  
        // Display name
        System.out.println("The Display name"
                           + " for the locale is: "
                           + display_name);
    }
}


Output:

The Display name for the locale is: 
Australian Eastern Standard Time (New South Wales)

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#getDisplayName(java.util.Locale)

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32427 POSTS0 COMMENTS
Milvus
103 POSTS0 COMMENTS
Nango Kala
6803 POSTS0 COMMENTS
Nicole Veronica
11944 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12014 POSTS0 COMMENTS
Shaida Kate Naidoo
6934 POSTS0 COMMENTS
Ted Musemwa
7188 POSTS0 COMMENTS
Thapelo Manthata
6882 POSTS0 COMMENTS
Umr Jansen
6867 POSTS0 COMMENTS