Class java.util.SimpleTimeZone
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.util.SimpleTimeZone

Object
   |
   +----TimeZone
           |
           +----java.util.SimpleTimeZone

public class SimpleTimeZone
extends TimeZone
SimpleTimeZone is a concrete subclass of TimeZone that represents a time zone for use with a Gregorian calendar. This class does not handle historical changes.

Use a negative value for dayOfWeekInMonth to indicate that SimpleTimeZone should count from the end of the month backwards. For example, Daylight Savings Time ends at the last (dayOfWeekInMonth = -1) Sunday in October, at 2 AM in standard time.

Version:
1.16 01/12/98
Author:
David Goldsmith, Mark Davis, Chen-Lieh Huang, Alan Liu
See Also:
Calendar, GregorianCalendar, TimeZone

Constructor Index

 o java.util.SimpleTimeZone(int, String)
Constructs a SimpleTimeZone with the given base time zone offset from GMT and time zone ID.
 o java.util.SimpleTimeZone(int, String, int, int, int, int, int, int, int, int)
Construct a SimpleTimeZone with the given base time zone offset from GMT, time zone ID, time to start and end the daylight time.

Method Index

 o clone()
Overrides Cloneable
 o equals(Object)
Compares the equality of two SimpleTimeZone objects.
 o getOffset(int, int, int, int, int, int)
Overrides TimeZone Gets offset, for current date, modified in case of daylight savings.
 o getRawOffset()
Overrides TimeZone Gets the GMT offset for this time zone.
 o hashCode()
Override hashCode.
 o inDaylightTime(Date)
Overrides TimeZone Queries if the given date is in Daylight Savings Time.
 o setEndRule(int, int, int, int)
Sets the daylight savings ending rule.
 o setRawOffset(int)
Overrides TimeZone Sets the base time zone offset to GMT.
 o setStartRule(int, int, int, int)
Sets the daylight savings starting rule.
 o setStartYear(int)
Sets the daylight savings starting year.
 o toString()
Return a string representation of this time zone.
 o useDaylightTime()
Overrides TimeZone Queries if this time zone uses Daylight Savings Time.

Constructors

 o SimpleTimeZone
public SimpleTimeZone(int rawOffset,
                      String ID)
Constructs a SimpleTimeZone with the given base time zone offset from GMT and time zone ID. Timezone IDs can be obtained from TimeZone.getAvailableIDs. Normally you should use TimeZone.getDefault to construct a TimeZone.

Parameters:
rawOffset - The given base time zone offset to GMT.
ID - The time zone ID which is obtained from TimeZone.getAvailableIDs.
 o SimpleTimeZone
public SimpleTimeZone(int rawOffset,
                      String ID,
                      int startMonth,
                      int startDay,
                      int startDayOfWeek,
                      int startTime,
                      int endMonth,
                      int endDay,
                      int endDayOfWeek,
                      int endTime)
Construct a SimpleTimeZone with the given base time zone offset from GMT, time zone ID, time to start and end the daylight time. Timezone IDs can be obtained from TimeZone.getAvailableIDs. Normally you should use TimeZone.getDefault to create a TimeZone. For a time zone that does not use daylight saving time, do not use this constructor; instead you should use SimpleTimeZone(rawOffset, ID). By default, this constructor specifies day-of-week-in-month rules. That is, if the startDay is 1, and the startDayOfWeek is SUNDAY, then this indicates the first Sunday in the startMonth. A startDay of -1 likewise indicates the last Sunday. However, by using negative or zero values for certain parameters, other types of rules can be specified. Day of month. To specify an exact day of the month, such as March 1, set startDayOfWeek to zero. Day of week after day of month. To specify the first day of the week occurring on or after an exact day of the month, make the day of the week negative. For example, if startDay is 5 and startDayOfWeek is -MONDAY, this indicates the first Monday on or after the 5th day of the startMonth. Day of week before day of month. To specify the last day of the week occurring on or before an exact day of the month, make the day of the week and the day of the month negative. For example, if startDay is -21 and startDayOfWeek is -WEDNESDAY, this indicates the last Wednesday on or before the 21st of the startMonth. The above examples refer to the startMonth, startDay, and startDayOfWeek; the same applies for the endMonth, endDay, and endDayOfWeek.

Parameters:
rawOffset - The given base time zone offset to GMT.
ID - The time zone ID which is obtained from TimeZone.getAvailableIDs.
startMonth - The daylight savings starting month. Month is 0-based. eg, 0 for January.
startDay - The daylight savings starting day-of-week-in-month. Please see the member description for an example.
startDayOfWeek - The daylight savings starting day-of-week. Please see the member description for an example.
startTime - The daylight savings starting time. Please see the member description for an example.
endMonth - The daylight savings ending month. Month is 0-based. eg, 0 for January.
endDay - The daylight savings ending day-of-week-in-month. Please see the member description for an example.
endDayOfWeek - The daylight savings ending day-of-week. Please see the member description for an example.
endTime - The daylight savings ending time. Please see the member description for an example.

Methods

 o clone
public java.lang.Object clone()
Overrides Cloneable

Overrides:
clone in class TimeZone
 o equals
public boolean equals(Object obj)
Compares the equality of two SimpleTimeZone objects.

Parameters:
obj - The SimpleTimeZone object to be compared with.
Returns:
True if the given obj is the same as this SimpleTimeZone object; false otherwise.
Overrides:
equals in class Object
 o getOffset
public int getOffset(int era,
                     int year,
                     int month,
                     int day,
                     int dayOfWeek,
                     int millis)
Overrides TimeZone Gets offset, for current date, modified in case of daylight savings. This is the offset to add *to* UTC to get local time. Gets the time zone offset, for current date, modified in case of daylight savings. This is the offset to add *to* UTC to get local time. Assume that the start and end month are distinct, and that no rule refers to the end of February (e.g., last Sunday in February).

Parameters:
era - The era of the given date.
year - The year in the given date.
month - The month in the given date. Month is 0-based. e.g., 0 for January.
day - The day-in-month of the given date.
dayOfWeek - The day-of-week of the given date.
milliseconds - The millis in day in standard local time.
Returns:
The offset to add *to* GMT to get local time.
Overrides:
getOffset in class TimeZone
 o getRawOffset
public int getRawOffset()
Overrides TimeZone Gets the GMT offset for this time zone.

Overrides:
getRawOffset in class TimeZone
 o hashCode
public synchronized int hashCode()
Override hashCode. Generates the hash code for the SimpleDateFormat object

Overrides:
hashCode in class Object
 o inDaylightTime
public boolean inDaylightTime(Date date)
Overrides TimeZone Queries if the given date is in Daylight Savings Time.

Overrides:
inDaylightTime in class TimeZone
 o setEndRule
public void setEndRule(int month,
                       int dayOfWeekInMonth,
                       int dayOfWeek,
                       int time)
Sets the daylight savings ending rule. For example, Daylight Savings Time ends at the last (-1) Sunday in October, at 2 AM in standard time. Therefore, you can set the end rule by calling: setEndRule(TimeFields.OCTOBER, -1, TimeFields.SUNDAY, 2*60*60*1000);

Parameters:
month - The daylight savings ending month. Month is 0-based. eg, 0 for January.
dayOfWeekInMonth - The daylight savings ending day-of-week-in-month. Please see the member description for an example.
dayOfWeek - The daylight savings ending day-of-week. Please see the member description for an example.
time - The daylight savings ending time. Please see the member description for an example.
 o setRawOffset
public void setRawOffset(int offsetMillis)
Overrides TimeZone Sets the base time zone offset to GMT. This is the offset to add *to* UTC to get local time. Please see TimeZone.setRawOffset for descriptions on the parameter.

Overrides:
setRawOffset in class TimeZone
 o setStartRule
public void setStartRule(int month,
                         int dayOfWeekInMonth,
                         int dayOfWeek,
                         int time)
Sets the daylight savings starting rule. For example, Daylight Savings Time starts at the first Sunday in April, at 2 AM in standard time. Therefore, you can set the start rule by calling: setStartRule(TimeFields.APRIL, 1, TimeFields.SUNDAY, 2*60*60*1000);

Parameters:
month - The daylight savings starting month. Month is 0-based. eg, 0 for January.
dayOfWeekInMonth - The daylight savings starting day-of-week-in-month. Please see the member description for an example.
dayOfWeek - The daylight savings starting day-of-week. Please see the member description for an example.
time - The daylight savings starting time. Please see the member description for an example.
 o setStartYear
public void setStartYear(int year)
Sets the daylight savings starting year.

Parameters:
year - The daylight savings starting year.
 o toString
public java.lang.String toString()
Return a string representation of this time zone.

Returns:
a string representation of this time zone.
Overrides:
toString in class Object
 o useDaylightTime
public boolean useDaylightTime()
Overrides TimeZone Queries if this time zone uses Daylight Savings Time.

Overrides:
useDaylightTime in class TimeZone

All Packages  Class Hierarchy  This Package  Previous  Next  Index