Build 1.0_r1(from source)

java.util
Class SimpleTimeZone

java.lang.Object
  extended by java.util.TimeZone
      extended by java.util.SimpleTimeZone
All Implemented Interfaces:
Serializable, Cloneable

public class SimpleTimeZone
extends TimeZone

SimpleTimeZone represents a local time zone and its daylight savings time rules for the gregorian calendar.

See Also:
Calendar, TimeZone, Serialized Form

Field Summary
static int STANDARD_TIME
           
static int UTC_TIME
           
static int WALL_TIME
           
 
Fields inherited from class java.util.TimeZone
GMT, LONG, SHORT
 
Constructor Summary
SimpleTimeZone(int offset, String name)
          Constructs a new SimpleTimeZone using the specified offset for standard time from GMT and the specified time zone ID.
SimpleTimeZone(int offset, String name, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime)
          Constructs a new SimpleTimeZone using the specified offset for standard time from GMT, the specified time zone ID and the rules for daylight savings time.
SimpleTimeZone(int offset, String name, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime, int daylightSavings)
          Constructs a new SimpleTimeZone using the specified offset for standard time from GMT, the specified time zone ID and the rules for daylight savings time.
SimpleTimeZone(int offset, String name, int startMonth, int startDay, int startDayOfWeek, int startTime, int startTimeMode, int endMonth, int endDay, int endDayOfWeek, int endTime, int endTimeMode, int daylightSavings)
          Constructs a new SimpleTimeZone using the specified offset for standard time from GMT, the specified time zone ID, the rules for daylight savings time, and the modes indicating UTC, standard, or wall time.
 
Method Summary
 Object clone()
          Returns a new SimpleTimeZone with the same ID, rawOffset and daylight savings time rules as this SimpleTimeZone.
 boolean equals(Object object)
          Compares the specified object to this SimpleTimeZone and answer if they are equal.
 int getDSTSavings()
          Gets the daylight savings offset in milliseconds for this SimpleTimeZone.
 int getOffset(int era, int year, int month, int day, int dayOfWeek, int time)
          Gets the offset from GMT of this SimpleTimeZone for the specified date and time.
 int getOffset(long time)
          Gets the offset from GMT of this SimpleTimeZone for the specified date.
 int getRawOffset()
          Gets the offset for standard time from GMT for this SimpleTimeZone.
 int hashCode()
          Returns an integer hash code for the receiver.
 boolean hasSameRules(TimeZone zone)
          Returns if the specified TimeZone has the same raw offset and daylight savings time rules as this SimpleTimeZone.
 boolean inDaylightTime(Date time)
          Returns if the specified Date is in the daylight savings time period for this SimpleTimeZone.
 void setDSTSavings(int milliseconds)
          Sets the daylight savings offset in milliseconds for this SimpleTimeZone.
 void setEndRule(int month, int dayOfMonth, int time)
          Sets the rule which specifies the end of daylight savings time.
 void setEndRule(int month, int day, int dayOfWeek, int time)
          Sets the rule which specifies the end of daylight savings time.
 void setEndRule(int month, int day, int dayOfWeek, int time, boolean after)
          Sets the rule which specifies the end of daylight savings time.
 void setRawOffset(int offset)
          Sets the offset for standard time from GMT for this SimpleTimeZone.
 void setStartRule(int month, int dayOfMonth, int time)
          Sets the rule which specifies the start of daylight savings time.
 void setStartRule(int month, int day, int dayOfWeek, int time)
          Sets the rule which specifies the start of daylight savings time.
 void setStartRule(int month, int day, int dayOfWeek, int time, boolean after)
          Sets the rule which specifies the start of daylight savings time.
 void setStartYear(int year)
          Sets the starting year for daylight savings time in this SimpleTimeZone.
 String toString()
          Returns the string representation of this SimpleTimeZone.
 boolean useDaylightTime()
          Returns if this TimeZone has a daylight savings time period.
 
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
 

Field Detail

UTC_TIME

public static final int UTC_TIME
See Also:
Constant Field Values

STANDARD_TIME

public static final int STANDARD_TIME
See Also:
Constant Field Values

WALL_TIME

public static final int WALL_TIME
See Also:
Constant Field Values
Constructor Detail

SimpleTimeZone

public SimpleTimeZone(int offset,
                      String name)
Constructs a new SimpleTimeZone using the specified offset for standard time from GMT and the specified time zone ID.

Parameters:
offset - the offset from GMT of standard time in milliseconds
name - the time zone ID

SimpleTimeZone

public SimpleTimeZone(int offset,
                      String name,
                      int startMonth,
                      int startDay,
                      int startDayOfWeek,
                      int startTime,
                      int endMonth,
                      int endDay,
                      int endDayOfWeek,
                      int endTime)
Constructs a new SimpleTimeZone using the specified offset for standard time from GMT, the specified time zone ID and the rules for daylight savings time.

Parameters:
offset - the offset from GMT of standard time in milliseconds
name - the time zone ID
startMonth - the Calendar month in which daylight savings time starts
startDay - the occurrence of the day of the week on which daylight savings time starts
startDayOfWeek - the Calendar day of the week on which daylight savings time starts
startTime - the time of day in milliseconds on which daylight savings time starts
endMonth - the Calendar month in which daylight savings time ends
endDay - the occurrence of the day of the week on which daylight savings time ends
endDayOfWeek - the Calendar day of the week on which daylight savings time ends
endTime - the time of day in milliseconds standard time on which daylight savings time ends

SimpleTimeZone

public SimpleTimeZone(int offset,
                      String name,
                      int startMonth,
                      int startDay,
                      int startDayOfWeek,
                      int startTime,
                      int endMonth,
                      int endDay,
                      int endDayOfWeek,
                      int endTime,
                      int daylightSavings)
Constructs a new SimpleTimeZone using the specified offset for standard time from GMT, the specified time zone ID and the rules for daylight savings time.

Parameters:
offset - the offset from GMT of standard time in milliseconds
name - the time zone ID
startMonth - the Calendar month in which daylight savings time starts
startDay - the occurrence of the day of the week on which daylight savings time starts
startDayOfWeek - the Calendar day of the week on which daylight savings time starts
startTime - the time of day in milliseconds on which daylight savings time starts
endMonth - the Calendar month in which daylight savings time ends
endDay - the occurrence of the day of the week on which daylight savings time ends
endDayOfWeek - the Calendar day of the week on which daylight savings time ends
endTime - the time of day in milliseconds standard time on which daylight savings time ends
daylightSavings - the daylight savings time difference in milliseconds

SimpleTimeZone

public SimpleTimeZone(int offset,
                      String name,
                      int startMonth,
                      int startDay,
                      int startDayOfWeek,
                      int startTime,
                      int startTimeMode,
                      int endMonth,
                      int endDay,
                      int endDayOfWeek,
                      int endTime,
                      int endTimeMode,
                      int daylightSavings)
Constructs a new SimpleTimeZone using the specified offset for standard time from GMT, the specified time zone ID, the rules for daylight savings time, and the modes indicating UTC, standard, or wall time.

Parameters:
offset - the offset from GMT of standard time in milliseconds
name - the time zone ID
startMonth - the Calendar month in which daylight savings time starts
startDay - the occurrence of the day of the week on which daylight savings time starts
startDayOfWeek - the Calendar day of the week on which daylight savings time starts
startTime - the time of day in milliseconds on which daylight savings time starts
startTimeMode - the mode (UTC, standard, or wall time) of the start time value
endMonth - the Calendar month in which daylight savings time ends
endDay - the occurrence of the day of the week on which daylight savings time ends
endDayOfWeek - the Calendar day of the week on which daylight savings time ends
endTime - the time of day in milliseconds standard time on which daylight savings time ends
endTimeMode - the mode (UTC, standard, or wall time) of the end time value
daylightSavings - the daylight savings time difference in milliseconds
Method Detail

clone

public Object clone()
Returns a new SimpleTimeZone with the same ID, rawOffset and daylight savings time rules as this SimpleTimeZone.

Overrides:
clone in class TimeZone
Returns:
a shallow copy of this SimpleTimeZone
See Also:
Cloneable

equals

public boolean equals(Object object)
Compares the specified object to this SimpleTimeZone and answer if they are equal. The object must be an instance of SimpleTimeZone and have the same properties.

Overrides:
equals in class Object
Parameters:
object - the object to compare with this object
Returns:
true if the specified object is equal to this SimpleTimeZone, false otherwise
See Also:
hashCode()

getDSTSavings

public int getDSTSavings()
Gets the daylight savings offset in milliseconds for this SimpleTimeZone. If this SimpleTimezone does not observe daylight savings, returns 0.

Overrides:
getDSTSavings in class TimeZone
Returns:
the daylight savings offset in milliseconds

getOffset

public int getOffset(int era,
                     int year,
                     int month,
                     int day,
                     int dayOfWeek,
                     int time)
Gets the offset from GMT of this SimpleTimeZone for the specified date and time. The offset includes daylight savings time if the specified date and time are within the daylight savings time period.

Specified by:
getOffset in class TimeZone
Parameters:
era - the GregorianCalendar era, either GregorianCalendar.BC or GregorianCalendar.AD
year - the year
month - the Calendar month
day - the day of the month
dayOfWeek - the Calendar day of the week
time - the time of day in milliseconds
Returns:
the offset from GMT in milliseconds

getOffset

public int getOffset(long time)
Gets the offset from GMT of this SimpleTimeZone for the specified date. The offset includes daylight savings time if the specified date is within the daylight savings time period.

Overrides:
getOffset in class TimeZone
Parameters:
time - the date in milliseconds since January 1, 1970 00:00:00 GMT
Returns:
the offset from GMT in milliseconds

getRawOffset

public int getRawOffset()
Gets the offset for standard time from GMT for this SimpleTimeZone.

Specified by:
getRawOffset in class TimeZone
Returns:
the offset from GMT of standard time in milliseconds

hashCode

public int hashCode()
Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Overrides:
hashCode in class Object
Returns:
the receiver's hash
See Also:
equals(java.lang.Object)

hasSameRules

public boolean hasSameRules(TimeZone zone)
Returns if the specified TimeZone has the same raw offset and daylight savings time rules as this SimpleTimeZone.

Overrides:
hasSameRules in class TimeZone
Parameters:
zone - a TimeZone
Returns:
true when the TimeZones have the same raw offset and daylight savings time rules, false otherwise

inDaylightTime

public boolean inDaylightTime(Date time)
Returns if the specified Date is in the daylight savings time period for this SimpleTimeZone.

Specified by:
inDaylightTime in class TimeZone
Parameters:
time - a Date
Returns:
true when the Date is in the daylight savings time period, false otherwise

setDSTSavings

public void setDSTSavings(int milliseconds)
Sets the daylight savings offset in milliseconds for this SimpleTimeZone.

Parameters:
milliseconds - the daylight savings offset in milliseconds

setEndRule

public void setEndRule(int month,
                       int dayOfMonth,
                       int time)
Sets the rule which specifies the end of daylight savings time.

Parameters:
month - the Calendar month in which daylight savings time ends
dayOfMonth - the Calendar day of the month on which daylight savings time ends
time - the time of day in milliseconds standard time on which daylight savings time ends

setEndRule

public void setEndRule(int month,
                       int day,
                       int dayOfWeek,
                       int time)
Sets the rule which specifies the end of daylight savings time.

Parameters:
month - the Calendar month in which daylight savings time ends
day - the occurrence of the day of the week on which daylight savings time ends
dayOfWeek - the Calendar day of the week on which daylight savings time ends
time - the time of day in milliseconds standard time on which daylight savings time ends

setEndRule

public void setEndRule(int month,
                       int day,
                       int dayOfWeek,
                       int time,
                       boolean after)
Sets the rule which specifies the end of daylight savings time.

Parameters:
month - the Calendar month in which daylight savings time ends
day - the Calendar day of the month
dayOfWeek - the Calendar day of the week on which daylight savings time ends
time - the time of day in milliseconds on which daylight savings time ends
after - selects the day after or before the day of month

setRawOffset

public void setRawOffset(int offset)
Sets the offset for standard time from GMT for this SimpleTimeZone.

Specified by:
setRawOffset in class TimeZone
Parameters:
offset - the offset from GMT of standard time in milliseconds

setStartRule

public void setStartRule(int month,
                         int dayOfMonth,
                         int time)
Sets the rule which specifies the start of daylight savings time.

Parameters:
month - the Calendar month in which daylight savings time starts
dayOfMonth - the Calendar day of the month on which daylight savings time starts
time - the time of day in milliseconds on which daylight savings time starts

setStartRule

public void setStartRule(int month,
                         int day,
                         int dayOfWeek,
                         int time)
Sets the rule which specifies the start of daylight savings time.

Parameters:
month - the Calendar month in which daylight savings time starts
day - the occurrence of the day of the week on which daylight savings time starts
dayOfWeek - the Calendar day of the week on which daylight savings time starts
time - the time of day in milliseconds on which daylight savings time starts

setStartRule

public void setStartRule(int month,
                         int day,
                         int dayOfWeek,
                         int time,
                         boolean after)
Sets the rule which specifies the start of daylight savings time.

Parameters:
month - the Calendar month in which daylight savings time starts
day - the Calendar day of the month
dayOfWeek - the Calendar day of the week on which daylight savings time starts
time - the time of day in milliseconds on which daylight savings time starts
after - selects the day after or before the day of month

setStartYear

public void setStartYear(int year)
Sets the starting year for daylight savings time in this SimpleTimeZone. Years before this start year will always be in standard time.

Parameters:
year - the starting year

toString

public String toString()
Returns the string representation of this SimpleTimeZone.

Overrides:
toString in class Object
Returns:
the string representation of this SimpleTimeZone

useDaylightTime

public boolean useDaylightTime()
Returns if this TimeZone has a daylight savings time period.

Specified by:
useDaylightTime in class TimeZone
Returns:
true if this time zone has a daylight savings time period, false otherwise

Build 1.0_r1(from source)

Please submit a feedback, bug or feature