1 *java.util.TimeZone* *TimeZone* TimeZone represents a time zone offset, and also
3 public abstract class TimeZone
4 extends |java.lang.Object|
5 implements |java.io.Serializable|
8 |java.util.TimeZone_Description|
9 |java.util.TimeZone_Fields|
10 |java.util.TimeZone_Constructors|
11 |java.util.TimeZone_Methods|
13 ================================================================================
15 *java.util.TimeZone_Fields*
16 |int_java.util.TimeZone.LONG|
17 |int_java.util.TimeZone.SHORT|
19 *java.util.TimeZone_Constructors*
20 |java.util.TimeZone()|Sole constructor.
22 *java.util.TimeZone_Methods*
23 |java.util.TimeZone.clone()|Creates a copy of this TimeZone.
24 |java.util.TimeZone.getAvailableIDs()|Gets all the available IDs supported.
25 |java.util.TimeZone.getAvailableIDs(int)|Gets the available IDs according to th
26 |java.util.TimeZone.getDefault()|Gets the default TimeZone for this host.
27 |java.util.TimeZone.getDisplayName()|Returns a name of this time zone suitable
28 |java.util.TimeZone.getDisplayName(boolean,int)|Returns a name of this time zon
29 |java.util.TimeZone.getDisplayName(boolean,int,Locale)|Returns a name of this t
30 |java.util.TimeZone.getDisplayName(Locale)|Returns a name of this time zone sui
31 |java.util.TimeZone.getDSTSavings()|Returns the amount of time to be added to l
32 |java.util.TimeZone.getID()|Gets the ID of this time zone.
33 |java.util.TimeZone.getOffset(int,int,int,int,int,int)|Gets the time zone offse
34 |java.util.TimeZone.getOffset(long)|Returns the offset of this time zone from U
35 |java.util.TimeZone.getRawOffset()|Returns the amount of time in milliseconds t
36 |java.util.TimeZone.getTimeZone(String)|Gets the TimeZone for the given ID.
37 |java.util.TimeZone.hasSameRules(TimeZone)|Returns true if this zone has the sa
38 |java.util.TimeZone.inDaylightTime(Date)|Queries if the given date is in daylig
39 |java.util.TimeZone.setDefault(TimeZone)|Sets the TimeZone that is returned by
40 |java.util.TimeZone.setID(String)|Sets the time zone ID.
41 |java.util.TimeZone.setRawOffset(int)|Sets the base time zone offset to GMT.
42 |java.util.TimeZone.useDaylightTime()|Queries if this time zone uses daylight s
44 *java.util.TimeZone_Description*
46 TimeZone represents a time zone offset, and also figures out daylight savings.
48 Typically, you get a TimeZone using getDefault which creates a TimeZone based
49 on the time zone where the program is running. For example, for a program
50 running in Japan, getDefault creates a TimeZone object based on Japanese
53 You can also get a TimeZone using getTimeZone along with a time zone ID. For
54 instance, the time zone ID for the U.S. Pacific Time zone is
55 "America/Los_Angeles". So, you can get a U.S. Pacific Time TimeZone object
58 TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
60 You can use the getAvailableIDs method to iterate through all the supported
61 time zone IDs. You can then choose a supported ID to get a TimeZone. If the
62 time zone you want is not represented by one of the supported IDs, then a
63 custom time zone ID can be specified to produce a TimeZone. The syntax of a
64 custom time zone ID is:
68 CustomID: GMT Sign Hours : Minutes GMT Sign Hours Minutes GMT Sign Hours Sign:
69 one of + - Hours: Digit Digit Digit Minutes: Digit Digit Digit: one of 0 1 2 3
72 Hours must be between 0 to 23 and Minutes must be between 00 to 59. For
73 example, "GMT+10" and "GMT+0010" mean ten hours and ten minutes ahead of GMT,
76 The format is locale independent and digits must be taken from the Basic Latin
77 block of the Unicode standard. No daylight saving time transition schedule can
78 be specified with a custom time zone ID. If the specified string doesn't match
79 the syntax, "GMT" is used.
81 When creating a TimeZone, the specified custom time zone ID is normalized in
84 NormalizedCustomID: GMT Sign TwoDigitHours : Minutes Sign: one of + -
85 TwoDigitHours: Digit Digit Minutes: Digit Digit Digit: one of 0 1 2 3 4 5 6 7 8
88 For example, TimeZone.getTimeZone("GMT-8").getID() returns "GMT-08:00".
90 Three-letter time zone IDs
92 For compatibility with JDK 1.1.x, some other three-letter time zone IDs (such
93 as "PST", "CTT", "AST") are also supported. However, their use is deprecated
94 because the same abbreviation is often used for multiple time zones (for
95 example, "CST" could be U.S. "Central Standard Time" and "China Standard
96 Time"), and the Java platform can then only recognize one of them.
100 *int_java.util.TimeZone.LONG*
102 A style specifier for getDisplayName() indicating a long name, such as "Pacific
106 *int_java.util.TimeZone.SHORT*
108 A style specifier for getDisplayName() indicating a short name, such as "PST."
112 *java.util.TimeZone()*
116 Sole constructor. (For invocation by subclass constructors, typically
120 *java.util.TimeZone.clone()*
122 public |java.lang.Object| clone()
124 Creates a copy of this TimeZone.
128 Returns: a clone of this TimeZone
130 *java.util.TimeZone.getAvailableIDs()*
132 public static synchronized |java.lang.String|[] getAvailableIDs()
134 Gets all the available IDs supported.
138 Returns: an array of IDs.
140 *java.util.TimeZone.getAvailableIDs(int)*
142 public static synchronized |java.lang.String|[] getAvailableIDs(int rawOffset)
144 Gets the available IDs according to the given time zone offset in milliseconds.
147 rawOffset - the given time zone GMT offset in milliseconds.
149 Returns: an array of IDs, where the time zone for that ID has the specified GMT offset.
150 For example, "America/Phoenix" and "America/Denver" both have
151 GMT-07:00, but differ in daylight savings behavior.
153 *java.util.TimeZone.getDefault()*
155 public static |java.util.TimeZone| getDefault()
157 Gets the default TimeZone for this host. The source of the default TimeZone may
158 vary with implementation.
162 Returns: a default TimeZone.
164 *java.util.TimeZone.getDisplayName()*
166 public final |java.lang.String| getDisplayName()
168 Returns a name of this time zone suitable for presentation to the user in the
169 default locale. This method returns the long name, not including daylight
170 savings. If the display name is not available for the locale, then this method
171 returns a string in the normalized custom ID format.
175 Returns: the human-readable name of this time zone in the default locale.
177 *java.util.TimeZone.getDisplayName(boolean,int)*
179 public final |java.lang.String| getDisplayName(
183 Returns a name of this time zone suitable for presentation to the user in the
184 default locale. If the display name is not available for the locale, then this
185 method returns a string in the normalized custom ID format.
188 daylight - if true, return the daylight savings name.
189 style - either LONG or SHORT
191 Returns: the human-readable name of this time zone in the default locale.
193 *java.util.TimeZone.getDisplayName(boolean,int,Locale)*
195 public |java.lang.String| getDisplayName(
198 java.util.Locale locale)
200 Returns a name of this time zone suitable for presentation to the user in the
201 specified locale. If the display name is not available for the locale, then
202 this method returns a string in the normalized custom ID format.
205 daylight - if true, return the daylight savings name.
206 style - either LONG or SHORT
207 locale - the locale in which to supply the display name.
209 Returns: the human-readable name of this time zone in the given locale.
211 *java.util.TimeZone.getDisplayName(Locale)*
213 public final |java.lang.String| getDisplayName(java.util.Locale locale)
215 Returns a name of this time zone suitable for presentation to the user in the
216 specified locale. This method returns the long name, not including daylight
217 savings. If the display name is not available for the locale, then this method
218 returns a string in the normalized custom ID format.
221 locale - the locale in which to supply the display name.
223 Returns: the human-readable name of this time zone in the given locale.
225 *java.util.TimeZone.getDSTSavings()*
227 public int getDSTSavings()
229 Returns the amount of time to be added to local standard time to get local wall
232 The default implementation always returns 3600000 milliseconds (i.e., one hour)
233 if this time zone observes Daylight Saving Time. Otherwise, 0 (zero) is
236 If an underlying TimeZone implementation subclass supports historical Daylight
237 Saving Time changes, this method returns the known latest daylight saving
242 Returns: the amount of saving time in milliseconds
244 *java.util.TimeZone.getID()*
246 public |java.lang.String| getID()
248 Gets the ID of this time zone.
252 Returns: the ID of this time zone.
254 *java.util.TimeZone.getOffset(int,int,int,int,int,int)*
256 public abstract int getOffset(
264 Gets the time zone offset, for current date, modified in case of daylight
265 savings. This is the offset to add to UTC to get local time.
267 This method returns a historically correct offset if an underlying TimeZone
268 implementation subclass supports historical Daylight Saving Time schedule and
272 era - the era of the given date.
273 year - the year in the given date.
274 month - the month in the given date. Month is 0-based. e.g., 0 for January.
275 day - the day-in-month of the given date.
276 dayOfWeek - the day-of-week of the given date.
277 milliseconds - the milliseconds in day in standard local time.
279 Returns: the offset in milliseconds to add to GMT to get local time.
281 *java.util.TimeZone.getOffset(long)*
283 public int getOffset(long date)
285 Returns the offset of this time zone from UTC at the specified date. If
286 Daylight Saving Time is in effect at the specified date, the offset value is
287 adjusted with the amount of daylight saving.
289 This method returns a historically correct offset value if an underlying
290 TimeZone implementation subclass supports historical Daylight Saving Time
291 schedule and GMT offset changes.
294 date - the date represented in milliseconds since January 1, 1970 00:00:00 GMT
296 Returns: the amount of time in milliseconds to add to UTC to get local time.
298 *java.util.TimeZone.getRawOffset()*
300 public abstract int getRawOffset()
302 Returns the amount of time in milliseconds to add to UTC to get standard time
303 in this time zone. Because this value is not affected by daylight saving time,
304 it is called raw offset.
306 If an underlying TimeZone implementation subclass supports historical GMT
307 offset changes, the method returns the raw offset value of the current date. In
308 Honolulu, for example, its raw offset changed from GMT-10:30 to GMT-10:00 in
309 1947, and this method always returns -36000000 milliseconds (i.e., -10 hours).
313 Returns: the amount of raw offset time in milliseconds to add to UTC.
315 *java.util.TimeZone.getTimeZone(String)*
317 public static synchronized |java.util.TimeZone| getTimeZone(java.lang.String ID)
319 Gets the TimeZone for the given ID.
322 ID - the ID for a TimeZone, either an abbreviation such as "PST", a full name such
323 as "America/Los_Angeles", or a custom ID such as "GMT-8:00". Note that
324 the support of abbreviations is for JDK 1.1.x compatibility only and
325 full names should be used.
327 Returns: the specified TimeZone, or the GMT zone if the given ID cannot be understood.
329 *java.util.TimeZone.hasSameRules(TimeZone)*
331 public boolean hasSameRules(java.util.TimeZone other)
333 Returns true if this zone has the same rule and offset as another zone. That
334 is, if this zone differs only in ID, if at all. Returns false if the other zone
338 other - the TimeZone object to be compared with
340 Returns: true if the other zone is not null and is the same as this one, with the
341 possible exception of the ID
343 *java.util.TimeZone.inDaylightTime(Date)*
345 public abstract boolean inDaylightTime(java.util.Date date)
347 Queries if the given date is in daylight savings time in this time zone.
350 date - the given Date.
352 Returns: true if the given date is in daylight savings time, false, otherwise.
354 *java.util.TimeZone.setDefault(TimeZone)*
356 public static void setDefault(java.util.TimeZone zone)
358 Sets the TimeZone that is returned by the getDefault method. If zone is null,
359 reset the default to the value it had originally when the VM first started.
362 zone - the new default time zone
364 *java.util.TimeZone.setID(String)*
366 public void setID(java.lang.String ID)
368 Sets the time zone ID. This does not change any other data in the time zone
372 ID - the new time zone ID.
374 *java.util.TimeZone.setRawOffset(int)*
376 public abstract void setRawOffset(int offsetMillis)
378 Sets the base time zone offset to GMT. This is the offset to add to UTC to get
381 If an underlying TimeZone implementation subclass supports historical GMT
382 offset changes, the specified GMT offset is set as the latest GMT offset and
383 the difference from the known latest GMT offset value is used to adjust all
384 historical GMT offset values.
387 offsetMillis - the given base time zone offset to GMT.
389 *java.util.TimeZone.useDaylightTime()*
391 public abstract boolean useDaylightTime()
393 Queries if this time zone uses daylight savings time.
395 If an underlying TimeZone implementation subclass supports historical Daylight
396 Saving Time schedule changes, the method refers to the latest Daylight Saving
397 Time schedule information.
401 Returns: true if this time zone uses daylight savings time, false, otherwise.