加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090217132652/http://developer.android.com:80/reference/java/util/SimpleTimeZone.html
public class

SimpleTimeZone

extends TimeZone
java.lang.Object
   ↳ java.util.TimeZone
     ↳ java.util.SimpleTimeZone

Class Overview

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

See Also

Summary

Constants
int STANDARD_TIME
int UTC_TIME
int WALL_TIME
[Expand]
Inherited Constants
From class java.util.TimeZone
Public Constructors
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.
Public Methods
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.
boolean hasSameRules(TimeZone zone)
Returns if the specified TimeZone has the same raw offset and daylight savings time rules as this SimpleTimeZone.
synchronized int hashCode()
Returns an integer hash code for the receiver.
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 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 setEndRule(int month, int dayOfMonth, int time)
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.
[Expand]
Inherited Methods
From class java.util.TimeZone
From class java.lang.Object

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
See Also

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
See Also

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.

Parameters
zone a TimeZone
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.

Returns
  • the receiver's hash
See Also

public boolean inDaylightTime (Date time)

Returns if the specified Date is in the daylight savings time period for this SimpleTimeZone.

Parameters
time a Date
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.

Parameters
year the starting year

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