The getTimeZone() method of TimeZone class in Java is used to know the actual TimeZone for any passed TimeZone ID.
public static TimeZone getTimeZone(String the_ID)
Parameters: The method takes one parameter the_ID of string datatype which refers to the ID of which the TimeZone is needed to be known.
Return Value: The method either returns the specified TimeZone for the passed ID or the GMT zone if the specified ID cannot be understood by the program.
Below programs illustrate the working of getTimeZone() Method of TimeZone:
The TimeZone is: sun.util.calendar.ZoneInfo[id="GMT+05:30", offset=19800000, dstSavings=0, useDaylight=false, transitions=0, lastRule=null]
The TimeZone is: sun.util.calendar.ZoneInfo[id="GMT-03:30", offset=-12600000, dstSavings=0, useDaylight=false, transitions=0, lastRule=null]
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.