java.util.SimpleTimeZone
java.util.TimeZone
None
None
New as of JDK 1.1
The SimpleTimeZone class is a concrete subclass of the abstract TimeZone class. SimpleTimeZone represents a time zone offset for use with GregorianCalendar. SimpleTimeZone does not take into account the historical vicissitudes of daylight savings time, however. Instead, it assumes that the shifts to and from daylight savings time always occur at the same time of the year.
Normally, SimpleTimeZone objects are not created directly, but instead obtained by calling TimeZone.getDefault(). This method creates a subclass of TimeZone that is appropriate for the current locale. You can also call TimeZone.getTimeZone() to obtain a TimeZone object for a specific time zone.
public class java.util.SimpleTimeZone extends java.util.TimeZone { // Constructors public SimpleTimeZone(int rawOffset, String ID); public SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDayOfWeekInMonth, int startDayOfWeek, int startTime, int endMonth, int endDayOfWeekInMonth, int endDayOfWeek, int endTime); // Instance Methods public Object clone(); public boolean equals(Object obj); public int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis); public int getRawOffset(); public synchronized int hashCode(); public boolean inDaylightTime(Date date); public void setEndRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time); public void setRawOffset(int offsetMillis); public void setStartRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time); public void setStartYear(int year); public boolean useDaylightTime(); }
The raw offset of this time zone from GMT, in milliseconds.
The ID of this time zone.
This constructor creates a SimpleTimeZone that uses the given offset from GMT and has the specified ID. This constructor creates a SimpleTimeZone that does not use daylight savings time.
public SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDayOfWeekInMonth, int startDayOfWeek, int startTime, int endMonth, int endDayOfWeekInMonth, int endDayOfWeek, int endTime)
The raw offset of this time zone from GMT, in milliseconds.
The ID of this time zone.
The month when daylight savings time begins.
The week in the month when daylight savings time begins.
The day of the week when daylight savings time begins.
The time of day when daylight savings time begins, in milliseconds.
The month when daylight savings time ends.
The week in the month when daylight savings time ends.
The day of the week when daylight savings time ends.
The time of day when daylight savings time ends, in milliseconds.
This constructor creates a SimpleTimeZone that uses the given offset from GMT, has the specified ID, and uses daylight savings time. Daylight savings time begins and ends at the specified dates and times.
For example, Brazil Eastern Time (BET) is three hours behind GMT. Daylight savings time for BET starts on the first Sunday in April at 2:00 AM, and ends on the last Sunday in October, also at 2:00 A.M. To construct a TimeZone that represents BET, you would use the following:
new SimpleTimeZone(-3 * 60 * 60 * 1000, "BET", Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000, Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000)
A copy of this SimpleTimeZone.
TimeZone.clone()
This method creates a copy of this SimpleTimeZone and returns it.
The object to be compared with this object.
true if the objects are equal; false if they are not.
Object.equals()
This method returns true if obj is an instance of SimpleTimeZone, and it contains the same value as the object this method is associated with.
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)
The era.
The year.
The month.
The day.
The day of the week.
The time of day in milliseconds.
An offset from GMT, in milliseconds.
TimeZone.getOffset()
This method calculates an offset from GMT for the given date for this SimpleTimeZone. In other words, the offset takes daylight savings time into account. The return value should be added to GMT to get local time.
An offset from GMT, in milliseconds.
TimeZone.getRawOffset()
This method returns the raw offset from GMT for this SimpleTimeZone. In other words, the offset does not take daylight savings time into account.
A hashcode for this SimpleTimeZone.
Object.hashCode()
This method returns a hashcode for this object.
The date to be tested.
true if the given date is between the start and end of daylight savings time for this SimpleTimeZone; false otherwise.
TimeZone.inDaylightTime()
This method returns a boolean value that indicates if the given date is in daylight savings time for this SimpleTimeZone.
public void setEndRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time)
The month when daylight savings time ends.
The week of the month when daylight savings time ends.
The day of the week when daylight savings time ends.
The time of day when daylight savings time ends, in milliseconds.
This method sets the time when daylight savings time ends for this SimpleTimeZone. For example, to set the end of daylight savings time to 2 A.M. on the last Sunday in October, you would use the following:
setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000)
The new raw offset from GMT, in milliseconds.
TimeZone.setRawOffset()
This method is used to set the raw offset value for this SimpleTimeZone.
public void setStartRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time)
The month when daylight savings time begins.
The week of the month when daylight savings time begins.
The day of the week when daylight savings time begins.
The time of day when daylight savings time begins, in milliseconds.
This method sets the time when daylight savings time begins for this SimpleTimeZone. For example, to set the beginning of daylight savings time to 2 A.M. on the first Sunday in April, you would use the following:
setEndRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000)
The year when daylight savings time begins.
This method sets the year after which the start and end rules for daylight savings time are observed.
true if this SimpleTimeZone uses daylight savings time; false otherwise.
TimeZone.useDaylightTime()
This method returns a boolean value that indicates whether or not this SimpleTimeZone uses daylight savings time.
Method | Inherited From | Method | Inherited From |
---|---|---|---|
finalize() |
Object |
getClass() |
Object |
getID() |
TimeZone |
notify() |
Object |
notifyAll() |
Object |
setID() |
TimeZone |
toString() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
Calendar, Cloneable, Date, GregorianCalendar, Locale, TimeZone