Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

TimeZone getID() Method in Java with Examples

  • Last Updated : 02 Jan, 2019

The getID() method of TimeZone class in Java is used to get official ID of a particular TimeZone.

Syntax:

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

public String getID()

Parameters: The method does not take any parameters.

Return Value: The method returns the ID of the TimeZone.



Below programs illustrate the working of getID() Method of TimeZone:
Example 1:




// Java code to illustrate getID() method
  
import java.util.*;
  
public class TimeZoneDemo {
    public static void main(String args[])
    {
  
        // Creating a TimeZone
        TimeZone offtime_zone 
= TimeZone.getTimeZone("Pacific/Pago_Pago");
  
        // Knowing the DST
        System.out.println("The ID is: " 
+ offtime_zone.getID());
    }
}
Output:
The ID is: Pacific/Pago_Pago

Example 2:




// Java code to illustrate getID() method
  
import java.util.*;
  
public class TimeZoneDemo {
    public static void main(String args[])
    {
  
        // Creating a TimeZone
        TimeZone offtime_zone 
= TimeZone.getTimeZone("Europe/Rome");
  
        // Knowing the DST
        System.out.println("The ID is: "
 + offtime_zone.getID());
    }
}
Output:
The ID is: Europe/Rome

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#getID()




My Personal Notes arrow_drop_up
Recommended Articles
Page :