Java TimeZone getDisplayName() Example
TimeZone class getDisplayName() method example. This example shows you how to use getDisplayName() method.
Syntax is : public final String getDisplayName(Locale locale)
Method returns a name of this time zone suitable for presentation to the user in the specified locale. This method returns the long name, not including daylight savings. If the display name is not available for the locale, then this method returns a string in the normalized custom ID format.
Here is the code.
/**
* @(#) GetDisplayName3TimeZone.java
* A class representing use of method getDisplayName() of TimeZone
class in java.util Package.
* @Version 27-May-2008
* @author Rose India Team
*/
import java.util.*;
class GetDisplayName3TimeZone {
public static void main( String args[] ){
// Create object of TimeZone class.
TimeZone obj = TimeZone.getTimeZone("Europe/Paris");
// Create object of Locale class.
Locale locale = new Locale("CHINESE", "CHINA");
// getDisplayName() method call.
String name = obj.getDisplayName(locale);
System.out.println("Time zone Name is : " + name);
}
} |
Output of the program.
| Time zone Name is : Central European Time |
|