GregorianCalendar.setTimeZone(TimeZone zone) has the following syntax.
public void setTimeZone(TimeZone zone)
In the following code shows how to use GregorianCalendar.setTimeZone(TimeZone zone) method.
//from w w w. ja v a2s . c om import java.util.*; public class Main { public static void main(String[] args) { GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance(); // set to another time zone cal.setTimeZone(TimeZone.getTimeZone("GMT")); System.out.println("New Time Zone:" + cal.getTimeZone().getDisplayName()); } }
The code above generates the following result.