GregorianCalendar setTimeZone() Method in Java
The java.util.GregorianCalendar.setTimeZone() method is an in-built method in Java which modifies the current time zone to a new time zone according to the parameter passed.
public void setTimeZone(TimeZone tz)
Parameters: The method takes one parameter tz of TimeZone object which specifies the new time zone value.
Return Values: This method does not return any value.
Input : IST Output : India Standard Time Input : UTC Output : Coordinated Universal Time
Below programs illustrate the java.util.GregorianCalendar.setTimeZone() function in Java:
Wed Jul 25 11:11:14 UTC 2018 Current Time Zone : Coordinated Universal Time New Time Zone : Central Standard Time
Wed Jul 25 11:11:21 UTC 2018 Current Time Zone : Coordinated Universal Time New Time Zone : India Standard Time
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.