java.util.SimpleTimeZone
SimpleTimeZone represents a local time zone and its daylight savings time
rules for the gregorian calendar.
Summary
Constants
|
|
|
Value |
|
int |
LONG |
The LONG display name style. |
1 |
0x00000001 |
int |
SHORT |
The SHORT display name style. |
0 |
0x00000000 |
Public Constructors
|
|
|
|
|
|
SimpleTimeZone(int offset, String name) |
|
|
|
|
|
|
SimpleTimeZone(int offset, String name, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime) |
|
|
|
|
|
|
SimpleTimeZone(int offset, String name, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime, int daylightSavings) |
|
|
|
|
|
|
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) |
Public Methods
|
|
|
|
|
Object |
clone() |
|
|
|
|
|
boolean |
equals(Object object) |
|
|
|
|
|
int |
getDSTSavings() |
|
|
|
|
|
int |
getOffset(int era, int year, int month, int day, int dayOfWeek, int time) |
|
|
|
|
|
int |
getOffset(long time) |
|
|
|
|
|
int |
getRawOffset() |
|
|
|
|
|
boolean |
hasSameRules(TimeZone zone) |
|
synchronized |
|
|
|
int |
hashCode() |
|
|
|
|
|
boolean |
inDaylightTime(Date time) |
|
|
|
|
|
void |
setDSTSavings(int milliseconds) |
|
|
|
|
|
void |
setEndRule(int month, int day, int dayOfWeek, int time) |
|
|
|
|
|
void |
setEndRule(int month, int day, int dayOfWeek, int time, boolean after) |
|
|
|
|
|
void |
setEndRule(int month, int dayOfMonth, int time) |
|
|
|
|
|
void |
setRawOffset(int offset) |
|
|
|
|
|
void |
setStartRule(int month, int dayOfMonth, int time) |
|
|
|
|
|
void |
setStartRule(int month, int day, int dayOfWeek, int time) |
|
|
|
|
|
void |
setStartRule(int month, int day, int dayOfWeek, int time, boolean after) |
|
|
|
|
|
void |
setStartYear(int year) |
|
|
|
|
|
String |
toString() |
|
|
|
|
|
boolean |
useDaylightTime() |
clone,
getAvailableIDs,
getAvailableIDs,
getDSTSavings,
getDefault,
getDisplayName,
getDisplayName,
getDisplayName,
getDisplayName,
getID,
getOffset,
getOffset,
getRawOffset,
getTimeZone,
hasSameRules,
inDaylightTime,
setDefault,
setID,
setRawOffset,
useDaylightTime
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
public
static
final
int
STANDARD_TIME
Constant Value:
1
(0x00000001)
public
static
final
int
UTC_TIME
Constant Value:
2
(0x00000002)
public
static
final
int
WALL_TIME
Constant Value:
0
(0x00000000)
Public Constructors
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
|
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
|
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
|
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
|
Public Methods
public
Object
clone()
Returns a new SimpleTimeZone with the same ID, rawOffset and daylight
savings time rules as this SimpleTimeZone.
Returns
- a shallow copy of this SimpleTimeZone
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.
Parameters
object
| the object to compare with this object |
Returns
- true if the specified object is equal to this SimpleTimeZone,
false otherwise
public
int
getDSTSavings()
Gets the daylight savings offset in milliseconds for this SimpleTimeZone.
If this SimpleTimezone does not observe daylight savings, returns 0.
Returns
- the daylight savings offset in milliseconds
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.
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
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.
Parameters
time
| the date in milliseconds since January 1, 1970 00:00:00 GMT |
Returns
- the offset from GMT in milliseconds
public
int
getRawOffset()
Gets the offset for standard time from GMT for this SimpleTimeZone.
Returns
- the offset from GMT of standard time in milliseconds
public
boolean
hasSameRules(TimeZone zone)
Returns if the specified TimeZone has the same raw offset and daylight
savings time rules as this SimpleTimeZone.
Returns
- true when the TimeZones have the same raw offset and daylight
savings time rules, false otherwise
public
synchronized
int
hashCode()
Returns an integer hash code for the receiver. Objects which are equal
answer the same value for this method.
public
boolean
inDaylightTime(Date time)
Returns if the specified Date is in the daylight savings time period for
this SimpleTimeZone.
Returns
- true when the Date is in the daylight savings time period, false
otherwise
public
void
setDSTSavings(int milliseconds)
Sets the daylight savings offset in milliseconds for this SimpleTimeZone.
Parameters
milliseconds
| the daylight savings offset in milliseconds
|
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
|
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
|
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
|
public
void
setRawOffset(int offset)
Sets the offset for standard time from GMT for this SimpleTimeZone.
Parameters
offset
| the offset from GMT of standard time in milliseconds
|
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
|
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
|
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
|
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.
public
String
toString()
Returns the string representation of this SimpleTimeZone.
Returns
- the string representation of this SimpleTimeZone
public
boolean
useDaylightTime()
Returns if this TimeZone has a daylight savings time period.
Returns
- true if this time zone has a daylight savings time period, false
otherwise