- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the ID of this timezone in Java
In order to get the ID of this timezone in Java, we use the getDisplayName() method. The getDisplayName() returns a name of this time zone acceptable for display to the user in the default locale. In other words, the name returned by the getDisplayName() is user friendly.
Declaration − The java.util.TimeZone.getDisplayName() is declared as follows −
public final String getDisplayName()
Let us see a program to get the ID of this timezone in Java −
Example
import java.util.*; public class Example { public static void main( String args[] ) { // creating default object of TimeZone TimeZone obj = TimeZone.getDefault(); System.out.println("Default timezone object:
" + obj); // getting the default name which is readable by the user String name = obj.getDisplayName(); System.out.println("Display name of this timezone: " + name); } }
Output
Default timezone object: sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null] Display name of this timezone: Coordinated Universal Time
- Related Articles
- Java Program to get timezone id strings
- Get the free space of this partition in Java
- Get the usable space of this partition in Java
- Get the total space of this partition in Java
- How can we get an ID of the running process in Java 9?
- Display TimeZone in z format in Java
- Display TimeZone in zzzz format in Java
- Create a copy of a TimeZone object in Java
- Specify the TimeZone explicitly for Gregorian Calendar in Java
- Java Program to get the number of hours in this duration
- Java Program to get the number of minutes in this duration
- How to get the value of id attribute in jQuery?
- Get unix timestamp from string without setting default timezone in PHP
- How to get the value of the id attribute a link in JavaScript?
- How to get device id in android?

Advertisements