In this section, you will learn how to obtain the System's TimeZone. The Time Zone is basically the uniform standard time usually referred to as the local time. We have used the instance of the class TimeZone in order to get the timeZone by using the method Calendar.getInstance().getTimeZone().
tz.getDisplayName()- This method returns the name of the time zone.
tz.getID()- This method returns the id of the time zone.
In this example, we want to display the System's Time zone.For this we consider a class GetSystemTimeZone,Inside the main method, we use the instance of class Time Zone to obtain the time zone of the specified region by calling Calendar.getInstance( ).getTimeZone( ) method. The System.out.print ln is used to display the output by calling the following given below method-
1)getDisplayName( )-Provides you the name of time zone.
2)getID( )- Provides you the id of time zone.
On Execution of the program code, The code returns you Time zone and ID.
Here is the code of GetSystemTimeZone.java
Output will be displayed as:
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: November 1, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles