java.util.TimeZone.getDisplayName() Method

Advertisements


Description

The getDisplayName(Locale locale) method is used to get a name of this time zone suitable for presentation to the user in the specified locale.

Declaration

Following is the declaration for java.util.TimeZone.getDisplayName() method.

public final String getDisplayName(Locale locale)

Parameters

  • locale--This is the locale in which to supply the display name.

Return Value

The method call returns the human-readable name of this time zone in the given locale.It can also return the default locale if the given locale is not recognized.

Exception

  • NA

Example

The following example shows the usage of java.util.TimeZone.getDisplayName()

package com.tutorialspoint;

import java.util.*;

public class TimeZoneDemo {
   public static void main( String args[] ){
       
      // create default time zone object
      TimeZone timezone = TimeZone.getTimeZone("Europe/Paris");
      
      // create locale
      Locale locale = new Locale("CHINESE", "CHINA");
      
      // get display name for specific locale
      String disname=timezone.getDisplayName(locale);       
         
      // checking display name         
      System.out.println("Display name is :" + disname);
   }    
}

Let us compile and run the above program, this will produce the following result.

Display name is :Central European Time



Advertisements
Advertisements