Java TimeZone getTimeZone() Example
TimeZone class getTimeZone() method example. This example shows you how to use getTimeZone() method.
Syntax is : public static TimeZone getTimeZone(String ID)
This method returns the TimeZone for the given ID.
Here is the code.
/**
* @(#) GetTimeZoneTimeZone.java
* A class representing use of method getTimeZone() of TimeZone
class in java.util Package.
* @Version 27-May-2008
* @author Rose India Team
*/
import java.util.*;
class GetTimeZoneTimeZone {
public static void main( String args[] ){
/* getTimeZone() method call for specified time zone. This is static
method. */
TimeZone timeZone = TimeZone.getTimeZone("Europe/Paris");
System.out.println("Time Zone for specified Id is :\n" +timeZone+"\n");
timeZone = TimeZone.getTimeZone("America/Los_Angeles");
System.out.println("Time Zone for next specified Id is :\n" + timeZone);
}
} |
Output of the program.
Time Zone for specified Id is :
sun.util.calendar.ZoneInfo[id="Europe/Paris",offset=3600000,dstSavings=3600000,useDaylight=true,
transitions=184,lastRule=java.util.SimpleTimeZone[id=Europe/Paris,offset=3600000,
dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,
startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,
endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
Time Zone for next specified Id is :
sun.util.calendar.ZoneInfo[id="America/Los_Angeles",offset=-28800000,dstSavings=3600000,
useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZone[id=America/Los_Angeles,
offset=-28800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,
startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,
endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]] |
|