java.util.TimeZone.getDisplayName() Method


Advertisements


Description

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

Declaration

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

public final String getDisplayName()

Parameters

NA

Return Value

The method call returns the human-readable name of this time zone in the default locale.

Exception

NA

Example

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

Live Demo
package com.tutorialspoint;

import java.util.*;

public class TimeZoneDemo {
   public static void main( String args[] ) {

      // create default time zone object
      TimeZone timezonedefault = TimeZone.getDefault();

      // get display name
      String disname = timezonedefault.getDisplayName(); 
      
      // 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 :India Standard Time

java_util_timezone.htm

Advertisements