Javatpoint Logo
Javatpoint Logo

Java TimeZone class

Java TimeZone class represents a time zone offset, and also figures out daylight savings. It inherits the Object class.


Java TimeZone class declaration

Let's see the declaration of java.util.TimeZone class.

Methods of Java TimeZone

Method Description
static String[] getAvailableIDs() It is used to get all the available IDs supported.
static TimeZone getDefault() It is used to get the default TimeZone for this host.
String getDisplayName() It is used to return a name of this time zone suitable for presentation to the user in the default locale.
String getID() It is used to get the ID of this time zone
int getOffset(long date) It is used to return the offset of this time zone from UTC at the specified date.
void setID(String ID) It is used to set the time zone ID

Java TimeZone class Example: getAvailableIDs()

Test it Now

Output:

In TimeZone class available Ids are: 
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau and so on ....

Java TimeZone class Example: getOffset()

Test it Now

Output:

The Offset value of TimeZone: 19800000

Java TimeZone class Example: getID()

Test it Now

Output:

Value of ID is: Asia/Kolkata

Java TimeZone class Example: getDisplayName()

Test it Now

Output:

Display name for default time zone: India Standard Time
Next TopicJava DateFormat




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA