Calendar.setTimeZone(TimeZone value)
Calendar class setTimeZone(TimeZone value) method example
Calendar class setTimeZone(TimeZone value) method example. This example shows you how to use setTimeZone(TimeZone value) method.This method Sets the time zone with the given time zone value.
Here is the code:-
/**
* @Program that Sets the time zone with the given time zone value.
* settimezonecalendar.java
* Author:-RoseIndia Team
* Date:-22-May-2008
*/
import java.util.*;
public class settimezonecalendar {
public static void main(String[] args) {
Calendar c=Calendar.getInstance();
TimeZone tz=TimeZone.getTimeZone("GMT");
//Sets the time zone with the given time zone value.
c.setTimeZone(tz);
System.out.println(c.getTimeZone());
}
} |
Output of the program:-
| sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null] |
|