Java GregorianCalendar .setTimeZone (TimeZone zone)
Syntax
GregorianCalendar.setTimeZone(TimeZone zone) has the following syntax.
public void setTimeZone(TimeZone zone)
Example
In the following code shows how to use GregorianCalendar.setTimeZone(TimeZone zone) method.
/*from www .ja va2 s. 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.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »