Java Calendar.setTimeZone(TimeZone value)
Syntax
Calendar.setTimeZone(TimeZone value) has the following syntax.
public void setTimeZone(TimeZone value)
Example
In the following code shows how to use Calendar.setTimeZone(TimeZone value) method.
/*from w w w . j av a 2 s .c om*/
import java.util.Calendar;
import java.util.TimeZone;
public class Main {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
System.out.println(cal.getTimeZone().getDisplayName());
TimeZone tz = TimeZone.getTimeZone("GMT");
// set the time zone with the given time zone value and print it
cal.setTimeZone(tz);
System.out.println(cal.getTimeZone().getDisplayName());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »