java.util
public class SimpleTimeZone extends TimeZone
See Also: Calendar GregorianCalendar
Field Summary | |
---|---|
static int | STANDARD_TIME
Constant to indicate that start and end times are specified in standard
time, without adjusting for daylight savings. |
static int | UTC_TIME
Constant to indicate that start and end times are specified in UTC. |
static int | WALL_TIME
Constant to indicate that start and end times are specified in wall
time, adjusting for daylight savings. |
Constructor Summary | |
---|---|
SimpleTimeZone(int rawOffset, String id)
Create a SimpleTimeZone with the given time offset
from GMT and without daylight savings. | |
SimpleTimeZone(int rawOffset, String id, int startMonth, int startDayOfWeekInMonth, int startDayOfWeek, int startTime, int endMonth, int endDayOfWeekInMonth, int endDayOfWeek, int endTime)
Create a SimpleTimeZone with the given time offset
from GMT and with daylight savings. | |
SimpleTimeZone(int rawOffset, String id, int startMonth, int startDayOfWeekInMonth, int startDayOfWeek, int startTime, int endMonth, int endDayOfWeekInMonth, int endDayOfWeek, int endTime, int dstSavings)
This constructs a new SimpleTimeZone that supports a daylight savings
rule. | |
SimpleTimeZone(int rawOffset, String id, int startMonth, int startDayOfWeekInMonth, int startDayOfWeek, int startTime, int startTimeMode, int endMonth, int endDayOfWeekInMonth, int endDayOfWeek, int endTime, int endTimeMode, int dstSavings)
This constructs a new SimpleTimeZone that supports a daylight savings
rule. |
Method Summary | |
---|---|
boolean | equals(Object o) |
int | getDSTSavings()
Gets the daylight savings offset. |
int | getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)
Gets the time zone offset, for current date, modified in case of
daylight savings. |
int | getRawOffset()
Returns the time zone offset to GMT in milliseconds, ignoring
day light savings. |
int | hashCode()
Generates the hashCode for the SimpleDateFormat object. |
boolean | hasSameRules(TimeZone other)
Test if the other time zone uses the same rule and only
possibly differs in ID. |
boolean | inDaylightTime(Date date)
Determines if the given date is in daylight savings time. |
void | setDSTSavings(int dstSavings)
Sets the daylight savings offset. |
void | setEndRule(int month, int day, int dayOfWeek, int time)
Sets the daylight savings end rule. |
void | setEndRule(int month, int day, int dayOfWeek, int time, boolean after)
Sets the daylight savings end rule. |
void | setEndRule(int month, int day, int time)
Sets the daylight savings end rule. |
void | setRawOffset(int rawOffset)
Sets the standard time zone offset to GMT. |
void | setStartRule(int month, int day, int dayOfWeek, int time)
Sets the daylight savings start rule. |
void | setStartRule(int month, int day, int dayOfWeek, int time, boolean after)
Sets the daylight savings start rule. |
void | setStartRule(int month, int day, int time)
Sets the daylight savings start rule. |
void | setStartYear(int year)
Sets the first year, where daylight savings applies. |
String | toString()
Returns a string representation of this SimpleTimeZone object. |
boolean | useDaylightTime()
Returns if this time zone uses daylight savings time. |
SimpleTimeZone
with the given time offset
from GMT and without daylight savings.Parameters: rawOffset the time offset from GMT in milliseconds. id The identifier of this time zone.
SimpleTimeZone
with the given time offset
from GMT and with daylight savings. The start/end parameters
can have different meaning (replace WEEKDAY with a real day of
week). Only the first two meanings were supported by earlier
versions of jdk.
day > 0, dayOfWeek = Calendar.WEEKDAY
day
-th
WEEKDAY
in the given month. day < 0, dayOfWeek = Calendar.WEEKDAY
-day
-th
WEEKDAY
counted from the end of the month. day > 0, dayOfWeek = 0
day
-th day of
the month. day > 0, dayOfWeek = -Calendar.WEEKDAY
day
-th day of the month. You must make sure that
this day lies in the same month. day < 0, dayOfWeek = -Calendar.WEEKDAY
-day
-th day of the month. You
must make sure that this day lies in the same month. Parameters: rawOffset The time offset from GMT in milliseconds. id The identifier of this time zone. startMonth The start month of daylight savings; use the constants in Calendar. startDayOfWeekInMonth A day in month or a day of week number, as described above. startDayOfWeek The start rule day of week; see above. startTime A time in millis in standard time. endMonth The end month of daylight savings; use the constants in Calendar. endDayOfWeekInMonth A day in month or a day of week number, as described above. endDayOfWeek The end rule day of week; see above. endTime A time in millis in standard time.
Throws: IllegalArgumentException if parameters are invalid or out of range.
Parameters: dstSavings the amount of savings for daylight savings time in milliseconds. This must be positive.
Since: 1.2
Parameters: startTimeMode the mode that start times are specified in. One of WALL_TIME, STANDARD_TIME, or UTC_TIME. endTimeMode the mode that end times are specified in. One of WALL_TIME, STANDARD_TIME, or UTC_TIME. dstSavings the amount of savings for daylight savings time in milliseconds. This must be positive.
Throws: IllegalArgumentException if parameters are invalid or out of range.
Since: 1.4
Returns: the daylight savings offset in milliseconds.
Since: 1.2
offset = cal.get(Calendar.ZONE_OFFSET)
+ cal.get(Calendar.DST_OFFSET);
This version doesn't suffer this inaccuracy.
The arguments don't follow the approach for setting start and end rules.
The day must be a positive number and dayOfWeek must be a positive value
from Calendar. dayOfWeek is redundant, but must match the other values
or an inaccurate result may be returned.
Parameters: era the era of the given date year the year of the given date month the month of the given date, 0 for January. day the day of month dayOfWeek the day of week; this must match the other fields. millis the millis in the day (in local standard time)
Returns: the time zone offset in milliseconds.
Throws: IllegalArgumentException if arguments are incorrect.
Returns: the time zone offset.
Returns: true if this zone uses the same rule.
Returns: true, if it is in daylight savings time, false otherwise.
Parameters: dstSavings the daylight savings offset in milliseconds.
Since: 1.2
setStartRule
or the result of
getOffset is undefined. For the parameters see the ten-argument
constructor above.
Parameters: month The end month of daylight savings. day A day in month, or a day of week in month. dayOfWeek A day of week, when daylight savings ends. time A time in millis in standard time.
See Also: SimpleTimeZone
setStartRule
or the result of
getOffset is undefined. For the parameters see the ten-argument
constructor above.
Note that this API isn't incredibly well specified. It appears that the
after flag must override the parameters, since normally, the day and
dayofweek can select this. I.e., if day < 0 and dayOfWeek < 0, on or
before mode is chosen. But if after == true, this implementation
overrides the signs of the other arguments. And if dayOfWeek == 0, it
falls back to the behavior in the other APIs. I guess this should be
checked against Sun's implementation.
Parameters: month The end month of daylight savings. day A day in month, or a day of week in month. dayOfWeek A day of week, when daylight savings ends. time A time in millis in standard time. after If true, day and dayOfWeek specify first day of week on or after day, else first day of week on or before.
Since: 1.2
See Also: SimpleTimeZone
setStartRule
or the result of
getOffset is undefined. For the parameters see the ten-argument
constructor above.
Parameters: month The end month of daylight savings. day A day in month, or a day of week in month. time A time in millis in standard time.
See Also: SimpleTimeZone
Parameters: rawOffset The time offset from GMT in milliseconds.
setEndRule
or the result of
getOffset is undefined. For the parameters see the ten-argument
constructor above.
Parameters: month The month where daylight savings start, zero based. You should use the constants in Calendar. day A day of month or day of week in month. dayOfWeek The day of week where daylight savings start. time The time in milliseconds standard time where daylight savings start.
Throws: IllegalArgumentException if parameters are out of range.
See Also: SimpleTimeZone
setEndRule
or the result of
getOffset is undefined. For the parameters see the ten-argument
constructor above.
Note that this API isn't incredibly well specified. It appears that the
after flag must override the parameters, since normally, the day and
dayofweek can select this. I.e., if day < 0 and dayOfWeek < 0, on or
before mode is chosen. But if after == true, this implementation
overrides the signs of the other arguments. And if dayOfWeek == 0, it
falls back to the behavior in the other APIs. I guess this should be
checked against Sun's implementation.
Parameters: month The month where daylight savings start, zero based. You should use the constants in Calendar. day A day of month or day of week in month. dayOfWeek The day of week where daylight savings start. time The time in milliseconds standard time where daylight savings start. after If true, day and dayOfWeek specify first day of week on or after day, else first day of week on or before.
Since: 1.2
See Also: SimpleTimeZone
setEndRule
or the result of
getOffset is undefined. For the parameters see the ten-argument
constructor above.
Parameters: month The month where daylight savings start, zero based. You should use the constants in Calendar. day A day of month or day of week in month. time The time in milliseconds standard time where daylight savings start.
Since: 1.2
See Also: SimpleTimeZone
Parameters: year the start year.
Returns: a string representation of this SimpleTimeZone object.
Returns: true, if we use daylight savings time, false otherwise.