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.
99 *int_java.util.TimeZone.LONG*
101 TimeZone represents a time zone offset, and also figures out daylight savings.
103 Typically, you get a TimeZone using getDefault which creates a TimeZone based
104 on the time zone where the program is running. For example, for a program
105 running in Japan, getDefault creates a TimeZone object based on Japanese
108 You can also get a TimeZone using getTimeZone along with a time zone ID. For
109 instance, the time zone ID for the U.S. Pacific Time zone is
110 "America/Los_Angeles". So, you can get a U.S. Pacific Time TimeZone object
113 TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
115 You can use the getAvailableIDs method to iterate through all the supported
116 time zone IDs. You can then choose a supported ID to get a TimeZone. If the
117 time zone you want is not represented by one of the supported IDs, then a
118 custom time zone ID can be specified to produce a TimeZone. The syntax of a
119 custom time zone ID is:
123 CustomID: GMT Sign Hours : Minutes GMT Sign Hours Minutes GMT Sign Hours Sign:
124 one of + - Hours: Digit Digit Digit Minutes: Digit Digit Digit: one of 0 1 2 3
127 Hours must be between 0 to 23 and Minutes must be between 00 to 59. For
128 example, "GMT+10" and "GMT+0010" mean ten hours and ten minutes ahead of GMT,
131 The format is locale independent and digits must be taken from the Basic Latin
132 block of the Unicode standard. No daylight saving time transition schedule can
133 be specified with a custom time zone ID. If the specified string doesn't match
134 the syntax, "GMT" is used.
136 When creating a TimeZone, the specified custom time zone ID is normalized in
137 the following syntax:
139 NormalizedCustomID: GMT Sign TwoDigitHours : Minutes Sign: one of + -
140 TwoDigitHours: Digit Digit Minutes: Digit Digit Digit: one of 0 1 2 3 4 5 6 7 8
143 For example, TimeZone.getTimeZone("GMT-8").getID() returns "GMT-08:00".
145 Three-letter time zone IDs
147 For compatibility with JDK 1.1.x, some other three-letter time zone IDs (such
148 as "PST", "CTT", "AST") are also supported. However, their use is deprecated
149 because the same abbreviation is often used for multiple time zones (for
150 example, "CST" could be U.S. "Central Standard Time" and "China Standard
151 Time"), and the Java platform can then only recognize one of them.
154 *int_java.util.TimeZone.SHORT*
156 TimeZone represents a time zone offset, and also figures out daylight savings.
158 Typically, you get a TimeZone using getDefault which creates a TimeZone based
159 on the time zone where the program is running. For example, for a program
160 running in Japan, getDefault creates a TimeZone object based on Japanese
163 You can also get a TimeZone using getTimeZone along with a time zone ID. For
164 instance, the time zone ID for the U.S. Pacific Time zone is
165 "America/Los_Angeles". So, you can get a U.S. Pacific Time TimeZone object
168 TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
170 You can use the getAvailableIDs method to iterate through all the supported
171 time zone IDs. You can then choose a supported ID to get a TimeZone. If the
172 time zone you want is not represented by one of the supported IDs, then a
173 custom time zone ID can be specified to produce a TimeZone. The syntax of a
174 custom time zone ID is:
178 CustomID: GMT Sign Hours : Minutes GMT Sign Hours Minutes GMT Sign Hours Sign:
179 one of + - Hours: Digit Digit Digit Minutes: Digit Digit Digit: one of 0 1 2 3
182 Hours must be between 0 to 23 and Minutes must be between 00 to 59. For
183 example, "GMT+10" and "GMT+0010" mean ten hours and ten minutes ahead of GMT,
186 The format is locale independent and digits must be taken from the Basic Latin
187 block of the Unicode standard. No daylight saving time transition schedule can
188 be specified with a custom time zone ID. If the specified string doesn't match
189 the syntax, "GMT" is used.
191 When creating a TimeZone, the specified custom time zone ID is normalized in
192 the following syntax:
194 NormalizedCustomID: GMT Sign TwoDigitHours : Minutes Sign: one of + -
195 TwoDigitHours: Digit Digit Minutes: Digit Digit Digit: one of 0 1 2 3 4 5 6 7 8
198 For example, TimeZone.getTimeZone("GMT-8").getID() returns "GMT-08:00".
200 Three-letter time zone IDs
202 For compatibility with JDK 1.1.x, some other three-letter time zone IDs (such
203 as "PST", "CTT", "AST") are also supported. However, their use is deprecated
204 because the same abbreviation is often used for multiple time zones (for
205 example, "CST" could be U.S. "Central Standard Time" and "China Standard
206 Time"), and the Java platform can then only recognize one of them.
210 *java.util.TimeZone()*
214 Sole constructor. (For invocation by subclass constructors, typically
218 *java.util.TimeZone.clone()*
220 public |java.lang.Object| clone()
222 Creates a copy of this TimeZone.
225 Returns: a clone of this TimeZone
226 *java.util.TimeZone.getAvailableIDs()*
228 public static synchronized |java.lang.String| getAvailableIDs()
230 Gets all the available IDs supported.
233 Returns: an array of IDs.
234 *java.util.TimeZone.getAvailableIDs(int)*
236 public static synchronized |java.lang.String| getAvailableIDs(int rawOffset)
238 Gets the available IDs according to the given time zone offset.
240 rawOffset - the given time zone GMT offset.
242 Returns: an array of IDs, where the time zone for that ID has the specified GMT offset.
243 For example, "America/Phoenix" and "America/Denver" both have
244 GMT-07:00, but differ in daylight savings behavior.
245 *java.util.TimeZone.getDefault()*
247 public static synchronized |java.util.TimeZone| getDefault()
249 Gets the default TimeZone for this host. The source of the default TimeZone may
250 vary with implementation.
253 Returns: a default TimeZone.
254 *java.util.TimeZone.getDisplayName()*
256 public final |java.lang.String| getDisplayName()
258 Returns a name of this time zone suitable for presentation to the user in the
259 default locale. This method returns the long name, not including daylight
260 savings. If the display name is not available for the locale, then this method
261 returns a string in the normalized custom ID format.
264 Returns: the human-readable name of this time zone in the default locale.
265 *java.util.TimeZone.getDisplayName(boolean,int)*
267 public final |java.lang.String| getDisplayName(
271 Returns a name of this time zone suitable for presentation to the user in the
272 default locale. If the display name is not available for the locale, then this
273 method returns a string in the normalized custom ID format.
275 daylight - if true, return the daylight savings name.
276 style - either LONG or SHORT
278 Returns: the human-readable name of this time zone in the default locale.
279 *java.util.TimeZone.getDisplayName(boolean,int,Locale)*
281 public |java.lang.String| getDisplayName(
284 java.util.Locale locale)
286 Returns a name of this time zone suitable for presentation to the user in the
287 specified locale. If the display name is not available for the locale, then
288 this method returns a string in the normalized custom ID format.
290 daylight - if true, return the daylight savings name.
291 style - either LONG or SHORT
292 locale - the locale in which to supply the display name.
294 Returns: the human-readable name of this time zone in the given locale or in the default
295 locale if the given locale is not recognized.
296 *java.util.TimeZone.getDisplayName(Locale)*
298 public final |java.lang.String| getDisplayName(java.util.Locale locale)
300 Returns a name of this time zone suitable for presentation to the user in the
301 specified locale. This method returns the long name, not including daylight
302 savings. If the display name is not available for the locale, then this method
303 returns a string in the normalized custom ID format.
305 locale - the locale in which to supply the display name.
307 Returns: the human-readable name of this time zone in the given locale or in the default
308 locale if the given locale is not recognized.
309 *java.util.TimeZone.getDSTSavings()*
311 public int getDSTSavings()
313 Returns the amount of time to be added to local standard time to get local wall
316 The default implementation always returns 3600000 milliseconds (i.e., one hour)
317 if this time zone observes Daylight Saving Time. Otherwise, 0 (zero) is
320 If an underlying TimeZone implementation subclass supports historical Daylight
321 Saving Time changes, this method returns the known latest daylight saving
325 Returns: the amount of saving time in milliseconds
326 *java.util.TimeZone.getID()*
328 public |java.lang.String| getID()
330 Gets the ID of this time zone.
333 Returns: the ID of this time zone.
334 *java.util.TimeZone.getOffset(int,int,int,int,int,int)*
336 public abstract int getOffset(
344 Gets the time zone offset, for current date, modified in case of daylight
345 savings. This is the offset to add to UTC to get local time.
347 This method returns a historically correct offset if an underlying TimeZone
348 implementation subclass supports historical Daylight Saving Time schedule and
351 era - the era of the given date.
352 year - the year in the given date.
353 month - the month in the given date. Month is 0-based. e.g., 0 for January.
354 day - the day-in-month of the given date.
355 dayOfWeek - the day-of-week of the given date.
356 milliseconds - the milliseconds in day in standard local time.
358 Returns: the offset in milliseconds to add to GMT to get local time.
359 *java.util.TimeZone.getOffset(long)*
361 public int getOffset(long date)
363 Returns the offset of this time zone from UTC at the specified date. If
364 Daylight Saving Time is in effect at the specified date, the offset value is
365 adjusted with the amount of daylight saving.
367 This method returns a historically correct offset value if an underlying
368 TimeZone implementation subclass supports historical Daylight Saving Time
369 schedule and GMT offset changes.
371 date - the date represented in milliseconds since January 1, 1970 00:00:00 GMT
373 Returns: the amount of time in milliseconds to add to UTC to get local time.
374 *java.util.TimeZone.getRawOffset()*
376 public abstract int getRawOffset()
378 Returns the amount of time in milliseconds to add to UTC to get standard time
379 in this time zone. Because this value is not affected by daylight saving time,
380 it is called raw offset.
382 If an underlying TimeZone implementation subclass supports historical GMT
383 offset changes, the method returns the raw offset value of the current date. In
384 Honolulu, for example, its raw offset changed from GMT-10:30 to GMT-10:00 in
385 1947, and this method always returns -36000000 milliseconds (i.e., -10 hours).
388 Returns: the amount of raw offset time in milliseconds to add to UTC.
389 *java.util.TimeZone.getTimeZone(String)*
391 public static synchronized |java.util.TimeZone| getTimeZone(java.lang.String ID)
393 Gets the TimeZone for the given ID.
395 ID - the ID for a TimeZone, either an abbreviation such as "PST", a full name such
396 as "America/Los_Angeles", or a custom ID such as "GMT-8:00". Note that
397 the support of abbreviations is for JDK 1.1.x compatibility only and
398 full names should be used.
400 Returns: the specified TimeZone, or the GMT zone if the given ID cannot be understood.
401 *java.util.TimeZone.hasSameRules(TimeZone)*
403 public boolean hasSameRules(java.util.TimeZone other)
405 Returns true if this zone has the same rule and offset as another zone. That
406 is, if this zone differs only in ID, if at all. Returns false if the other zone
409 other - the TimeZone object to be compared with
411 Returns: true if the other zone is not null and is the same as this one, with the
412 possible exception of the ID
413 *java.util.TimeZone.inDaylightTime(Date)*
415 public abstract boolean inDaylightTime(java.util.Date date)
417 Queries if the given date is in daylight savings time in this time zone.
419 date - the given Date.
421 Returns: true if the given date is in daylight savings time, false, otherwise.
422 *java.util.TimeZone.setDefault(TimeZone)*
424 public static synchronized void setDefault(java.util.TimeZone zone)
426 Sets the TimeZone that is returned by the getDefault method. If zone is null,
427 reset the default to the value it had originally when the VM first started.
429 zone - the new default time zone
431 *java.util.TimeZone.setID(String)*
433 public void setID(java.lang.String ID)
435 Sets the time zone ID. This does not change any other data in the time zone
438 ID - the new time zone ID.
440 *java.util.TimeZone.setRawOffset(int)*
442 public abstract void setRawOffset(int offsetMillis)
444 Sets the base time zone offset to GMT. This is the offset to add to UTC to get
447 If an underlying TimeZone implementation subclass supports historical GMT
448 offset changes, the specified GMT offset is set as the latest GMT offset and
449 the difference from the known latest GMT offset value is used to adjust all
450 historical GMT offset values.
452 offsetMillis - the given base time zone offset to GMT.
454 *java.util.TimeZone.useDaylightTime()*
456 public abstract boolean useDaylightTime()
458 Queries if this time zone uses daylight savings time.
460 If an underlying TimeZone implementation subclass supports historical Daylight
461 Saving Time schedule changes, the method refers to the latest Daylight Saving
462 Time schedule information.
465 Returns: true if this time zone uses daylight savings time, false, otherwise.