Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| J2ME Foundation
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## java.util
Class SimpleTimeZone

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

All Implemented Interfaces:
  Cloneable, Serializable

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.

See Also:
  `Calendar`, `GregorianCalendar`, `TimeZone`, Serialized Form

Fields inherited from class java.util.TimeZone
`LONG, SHORT`

Constructor Summary
`SimpleTimeZone(int rawOffset, String ID)` Constructs a SimpleTimeZone with the given base time zone offset from GMT and time zone ID.
`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.
`SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime, int dstSavings)` Constructor.

Method Summary
`Object` | `clone()` Overrides Cloneable
`boolean` | `equals(Object obj)` Compares the equality of two SimpleTimeZone objects.
`int` | `getDSTSavings()` Returns the amount of time in ms that the clock is advanced during DST.
`int` | `getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)` Returns the difference in milliseconds between local time and UTC, taking into account both the raw offset and the effect of daylight savings, for the specified date and time.
`int` | `getRawOffset()` Overrides TimeZone Gets the GMT offset for this time zone.
`int` | `hashCode()` Override hashCode.
`boolean` | `hasSameRules(TimeZone other)` Return true if this zone has the same rules and offset as another zone.
`boolean` | `inDaylightTime(Date date)` Overrides TimeZone Queries if the given date is in Daylight Savings Time.
`void` | `setDSTSavings(int millisSavedDuringDST)` Sets the amount of time in ms that the clock is advanced during DST.
`void` | `setEndRule(int month, int dayOfMonth, int time)` Sets the DST end rule to a fixed date within a month.
`void` | `setEndRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time)` Sets the daylight savings ending rule.
`void` | `setEndRule(int month, int dayOfMonth, int dayOfWeek, int time, boolean after)` Sets the DST end rule to a weekday before or after a give date within a month, e.g., the first Monday on or after the 8th.
`void` | `setRawOffset(int offsetMillis)` Overrides TimeZone Sets the base time zone offset to GMT.
`void` | `setStartRule(int month, int dayOfMonth, int time)` Sets the DST start rule to a fixed date within a month.
`void` | `setStartRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time)` Sets the daylight savings starting rule.
`void` | `setStartRule(int month, int dayOfMonth, int dayOfWeek, int time, boolean after)` Sets the DST start rule to a weekday before or after a give date within a month, e.g., the first Monday on or after the 8th.
`void` | `setStartYear(int year)` Sets the daylight savings starting year.
`String` | `toString()` Return a string representation of this time zone.
`boolean` | `useDaylightTime()` Overrides TimeZone Queries if this time zone uses Daylight Savings Time.

Methods inherited from class java.util.TimeZone
`getAvailableIDs, getAvailableIDs, getDefault, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getID, getTimeZone, setDefault, setID`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### 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.

### 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 in local wall time, which is standard time in this case. 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 in local wall time, which is daylight time in this case. Please see the member description for an example.
  Throws:
    `IllegalArgumentException` - the month, day, dayOfWeek, or time parameters are out of range for the start or end rule
  Since:
    JDK1.1

### SimpleTimeZone

    public SimpleTimeZone(int rawOffset,
                          String ID,
                          int startMonth,
                          int startDay,
                          int startDayOfWeek,
                          int startTime,
                          int endMonth,
                          int endDay,
                          int endDayOfWeek,
                          int endTime,
                          int dstSavings)

  Constructor. This constructor is identical to the 10-argument constructor, but also takes a dstSavings parameter.
  Parameters:
    `dstSavings` - The amount of time in ms saved during DST.
  Throws:
    `IllegalArgumentException` - the month, day, dayOfWeek, or time parameters are out of range for the start or end rule
  Since:
    1.2

Method Detail

### setStartYear

    public void setStartYear(int year)

  Sets the daylight savings starting year.
  Parameters:
    `year` - The daylight savings starting year.

### 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 in local wall time, which is standard time in this case. Please see the member description for an example.
  Throws:
    `IllegalArgumentException` - the month, dayOfWeekInMonth, dayOfWeek, or time parameters are out of range

### setStartRule

    public void setStartRule(int month,
                             int dayOfMonth,
                             int time)

  Sets the DST start rule to a fixed date within a month.
  Parameters:
    `month` - The month in which this rule occurs (0-based).
    `dayOfMonth` - The date in that month (1-based).
    `time` - The time of that day (number of millis after midnight) when DST takes effect in local wall time, which is standard time in this case.
  Throws:
    `IllegalArgumentException` - the month, dayOfMonth, or time parameters are out of range
  Since:
    1.2

### setStartRule

    public void setStartRule(int month,
                             int dayOfMonth,
                             int dayOfWeek,
                             int time,
                             boolean after)

  Sets the DST start rule to a weekday before or after a give date within a month, e.g., the first Monday on or after the 8th.
  Parameters:
    `month` - The month in which this rule occurs (0-based).
    `dayOfMonth` - A date within that month (1-based).
    `dayOfWeek` - The day of the week on which this rule occurs.
    `time` - The time of that day (number of millis after midnight) when DST takes effect in local wall time, which is standard time in this case.
    `after` - If true, this rule selects the first dayOfWeek on or after dayOfMonth. If false, this rule selects the last dayOfWeek on or before dayOfMonth.
  Throws:
    `IllegalArgumentException` - the month, dayOfMonth, dayOfWeek, or time parameters are out of range
  Since:
    1.2

### 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 in local wall time, which is daylight time in this case. Please see the member description for an example.
  Throws:
    `IllegalArgumentException` - the month, dayOfWeekInMonth, dayOfWeek, or time parameters are out of range

### setEndRule

    public void setEndRule(int month,
                           int dayOfMonth,
                           int time)

  Sets the DST end rule to a fixed date within a month.
  Parameters:
    `month` - The month in which this rule occurs (0-based).
    `dayOfMonth` - The date in that month (1-based).
    `time` - The time of that day (number of millis after midnight) when DST ends in local wall time, which is daylight time in this case.
  Throws:
    `IllegalArgumentException` - the month, dayOfMonth, or time parameters are out of range
  Since:
    1.2

### setEndRule

    public void setEndRule(int month,
                           int dayOfMonth,
                           int dayOfWeek,
                           int time,
                           boolean after)

  Sets the DST end rule to a weekday before or after a give date within a month, e.g., the first Monday on or after the 8th.
  Parameters:
    `month` - The month in which this rule occurs (0-based).
    `dayOfMonth` - A date within that month (1-based).
    `dayOfWeek` - The day of the week on which this rule occurs.
    `time` - The time of that day (number of millis after midnight) when DST ends in local wall time, which is daylight time in this case.
    `after` - If true, this rule selects the first dayOfWeek on or after dayOfMonth. If false, this rule selects the last dayOfWeek on or before dayOfMonth.
  Throws:
    `IllegalArgumentException` - the month, dayOfMonth, dayOfWeek, or time parameters are out of range
  Since:
    1.2

### getOffset

    public int getOffset(int era,
                         int year,
                         int month,
                         int day,
                         int dayOfWeek,
                         int millis)

  Returns the difference in milliseconds between local time and UTC, taking into account both the raw offset and the effect of daylight savings, for the specified date and time. This method assumes that the start and end month are distinct. It also uses a default `GregorianCalendar` object as its underlying calendar, such as for determining leap years. Do not use the result of this method with a calendar other than a default `GregorianCalendar`.

  Note: In general, clients should use `Calendar.get(ZONE_OFFSET) + Calendar.get(DST_OFFSET)` instead of calling this method.

  Overrides:
    `getOffset` in class `TimeZone`
  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.
    `millis` - The milliseconds in day in standard local time.
  Returns:
    The milliseconds to add to UTC to get local time.
  Throws:
    `IllegalArgumentException` - the era, month, day, dayOfWeek, or millis parameters are out of range

### getRawOffset

    public int getRawOffset()

  Overrides TimeZone Gets the GMT offset for this time zone.
  Overrides:
    `getRawOffset` in class `TimeZone`
  Following copied from class: `java.util.TimeZone`
  Returns:
    the unmodified offset to add *to* UTC to get local time.

### 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`
  Following copied from class: `java.util.TimeZone`
  Parameters:
    `offsetMillis` - the given base time zone offset to GMT.

### setDSTSavings

    public void setDSTSavings(int millisSavedDuringDST)

  Sets the amount of time in ms that the clock is advanced during DST.
  Parameters:
    `millisSavedDuringDST` - the number of milliseconds the time is advanced with respect to standard time when the daylight savings rules are in effect. A positive number, typically one hour (3600000).
  Since:
    1.2

### getDSTSavings

    public int getDSTSavings()

  Returns the amount of time in ms that the clock is advanced during DST.
  Returns:
    the number of milliseconds the time is advanced with respect to standard time when the daylight savings rules are in effect. A positive number, typically one hour (3600000).
  Since:
    1.2

### useDaylightTime

    public boolean useDaylightTime()

  Overrides TimeZone Queries if this time zone uses Daylight Savings Time.
  Overrides:
    `useDaylightTime` in class `TimeZone`
  Following copied from class: `java.util.TimeZone`
  Returns:
    true if this time zone uses daylight savings time, false, otherwise.

### inDaylightTime

    public boolean inDaylightTime(Date date)

  Overrides TimeZone Queries if the given date is in Daylight Savings Time.
  Overrides:
    `inDaylightTime` in class `TimeZone`
  Following copied from class: `java.util.TimeZone`
  Parameters:
    `date` - the given Date.
  Returns:
    true if the given date is in daylight savings time, false, otherwise.

### clone

    public Object clone()

  Overrides Cloneable
  Overrides:
    `clone` in class `TimeZone`
  Following copied from class: `java.lang.Object`
  Returns:
    a clone of this instance.
  Throws:
    `CloneNotSupportedException` - if the object's class does not support the `Cloneable` interface. Subclasses that override the `clone` method can also throw this exception to indicate that an instance cannot be cloned.
    `OutOfMemoryError` - if there is not enough memory.
  See Also:
    `Cloneable`

### hashCode

    public int hashCode()

  Override hashCode. Generates the hash code for the SimpleDateFormat object
  Overrides:
    `hashCode` in class `Object`
  Following copied from class: `java.lang.Object`
  Returns:
    a hash code value for this object.
  See Also:
    `Object.equals(java.lang.Object)`, `Hashtable`

### equals

    public boolean equals(Object obj)

  Compares the equality of two SimpleTimeZone objects.
  Overrides:
    `equals` in class `Object`
  Parameters:
    `obj` - The SimpleTimeZone object to be compared with.
  Returns:
    True if the given obj is the same as this SimpleTimeZone object; false otherwise.

### hasSameRules

    public boolean hasSameRules(TimeZone other)

  Return true if this zone has the same rules and offset as another zone.
  Overrides:
    `hasSameRules` in class `TimeZone`
  Parameters:
    `other` - the TimeZone object to be compared with
  Returns:
    true if the given zone has the same rules and offset as this one
  Since:
    1.2

### toString

    public String toString()

  Return a string representation of this time zone.
  Overrides:
    `toString` in class `Object`
  Returns:
    a string representation of this time zone.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| J2ME Foundation
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Java is a trademark or registred trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road,
Palo, Alto, California, 94303, U.S.A All Rights Reserved. < /font >