1:
38:
39:
40: package ;
41:
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48:
49:
66: public abstract class TimeZone implements java.io.Serializable, Cloneable
67: {
68:
69:
73: public static final int SHORT = 0;
74:
75:
79: public static final int LONG = 1;
80:
81:
84: private String ID;
85:
86:
89: private static TimeZone defaultZone0;
90:
91:
98: private static synchronized TimeZone defaultZone()
99: {
100:
101: if (defaultZone0 == null)
102: {
103: defaultZone0 = (TimeZone) AccessController.doPrivileged
104: (new PrivilegedAction()
105: {
106: public Object run()
107: {
108: TimeZone zone = null;
109:
110:
111: String tzid = System.getProperty("user.timezone");
112: if (tzid != null && !tzid.equals(""))
113: zone = getDefaultTimeZone(tzid);
114:
115:
116: if (zone == null)
117: zone = VMTimeZone.getDefaultTimeZoneId();
118:
119:
120: if (zone == null)
121: zone = getTimeZone ("GMT");
122:
123: return zone;
124: }
125: });
126: }
127:
128: return defaultZone0;
129: }
130:
131: private static final long serialVersionUID = 3581463369166924961L;
132:
133:
137: private static String zoneinfo_dir;
138:
139:
142: private static String[] availableIDs = null;
143:
144:
147: private static HashMap aliases0;
148:
149:
152: private static HashMap timezones0;
153:
156:
157: static HashMap timezones()
158: {
159: if (timezones0 == null)
160: {
161: HashMap timezones = new HashMap();
162: timezones0 = timezones;
163:
164: zoneinfo_dir = SystemProperties.getProperty("gnu.java.util.zoneinfo.dir");
165: if (zoneinfo_dir != null && !new File(zoneinfo_dir).isDirectory())
166: zoneinfo_dir = null;
167:
168: if (zoneinfo_dir != null)
169: {
170: aliases0 = new HashMap();
171:
172:
173:
174:
175: aliases0.put("ACT", "Australia/Darwin");
176: aliases0.put("AET", "Australia/Sydney");
177: aliases0.put("AGT", "America/Argentina/Buenos_Aires");
178: aliases0.put("ART", "Africa/Cairo");
179: aliases0.put("AST", "America/Juneau");
180: aliases0.put("BST", "Asia/Colombo");
181: aliases0.put("CAT", "Africa/Gaborone");
182: aliases0.put("CNT", "America/St_Johns");
183: aliases0.put("CST", "CST6CDT");
184: aliases0.put("CTT", "Asia/Brunei");
185: aliases0.put("EAT", "Indian/Comoro");
186: aliases0.put("ECT", "CET");
187: aliases0.put("EST", "EST5EDT");
188: aliases0.put("EST5", "EST5EDT");
189: aliases0.put("IET", "EST5EDT");
190: aliases0.put("IST", "Asia/Calcutta");
191: aliases0.put("JST", "Asia/Seoul");
192: aliases0.put("MIT", "Pacific/Niue");
193: aliases0.put("MST", "MST7MDT");
194: aliases0.put("MST7", "MST7MDT");
195: aliases0.put("NET", "Indian/Mauritius");
196: aliases0.put("NST", "Pacific/Auckland");
197: aliases0.put("PLT", "Indian/Kerguelen");
198: aliases0.put("PNT", "MST7MDT");
199: aliases0.put("PRT", "America/Anguilla");
200: aliases0.put("PST", "PST8PDT");
201: aliases0.put("SST", "Pacific/Ponape");
202: aliases0.put("VST", "Asia/Bangkok");
203: return timezones;
204: }
205:
206: TimeZone tz;
207:
208:
209: tz = new SimpleTimeZone(-11000 * 3600, "MIT");
210: timezones0.put("MIT", tz);
211: timezones0.put("Pacific/Apia", tz);
212: timezones0.put("Pacific/Midway", tz);
213: timezones0.put("Pacific/Niue", tz);
214: timezones0.put("Pacific/Pago_Pago", tz);
215: tz = new SimpleTimeZone
216: (-10000 * 3600, "America/Adak",
217: Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
218: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
219: timezones0.put("America/Adak", tz);
220: tz = new SimpleTimeZone(-10000 * 3600, "HST");
221: timezones0.put("HST", tz);
222: timezones0.put("Pacific/Fakaofo", tz);
223: timezones0.put("Pacific/Honolulu", tz);
224: timezones0.put("Pacific/Johnston", tz);
225: timezones0.put("Pacific/Rarotonga", tz);
226: timezones0.put("Pacific/Tahiti", tz);
227: tz = new SimpleTimeZone(-9500 * 3600, "Pacific/Marquesas");
228: timezones0.put("Pacific/Marquesas", tz);
229: tz = new SimpleTimeZone
230: (-9000 * 3600, "AST",
231: Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
232: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
233: timezones0.put("AST", tz);
234: timezones0.put("America/Anchorage", tz);
235: timezones0.put("America/Juneau", tz);
236: timezones0.put("America/Nome", tz);
237: timezones0.put("America/Yakutat", tz);
238: tz = new SimpleTimeZone(-9000 * 3600, "Pacific/Gambier");
239: timezones0.put("Pacific/Gambier", tz);
240: tz = new SimpleTimeZone
241: (-8000 * 3600, "America/Tijuana",
242: Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
243: Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
244: timezones0.put("America/Tijuana", tz);
245: tz = new SimpleTimeZone
246: (-8000 * 3600, "PST",
247: Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
248: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
249: timezones0.put("PST", tz);
250: timezones0.put("PST8PDT", tz);
251: timezones0.put("America/Dawson", tz);
252: timezones0.put("America/Los_Angeles", tz);
253: timezones0.put("America/Vancouver", tz);
254: timezones0.put("America/Whitehorse", tz);
255: timezones0.put("US/Pacific-New", tz);
256: tz = new SimpleTimeZone(-8000 * 3600, "Pacific/Pitcairn");
257: timezones0.put("Pacific/Pitcairn", tz);
258: tz = new SimpleTimeZone
259: (-7000 * 3600, "America/Chihuahua",
260: Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
261: Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
262: timezones0.put("America/Chihuahua", tz);
263: timezones0.put("America/Mazatlan", tz);
264: tz = new SimpleTimeZone(-7000 * 3600, "MST7");
265: timezones0.put("MST7", tz);
266: timezones0.put("PNT", tz);
267: timezones0.put("America/Dawson_Creek", tz);
268: timezones0.put("America/Hermosillo", tz);
269: timezones0.put("America/Phoenix", tz);
270: tz = new SimpleTimeZone
271: (-7000 * 3600, "MST",
272: Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
273: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
274: timezones0.put("MST", tz);
275: timezones0.put("MST7MDT", tz);
276: timezones0.put("America/Boise", tz);
277: timezones0.put("America/Cambridge_Bay", tz);
278: timezones0.put("America/Denver", tz);
279: timezones0.put("America/Edmonton", tz);
280: timezones0.put("America/Inuvik", tz);
281: timezones0.put("America/Shiprock", tz);
282: timezones0.put("America/Yellowknife", tz);
283: tz = new SimpleTimeZone
284: (-6000 * 3600, "America/Cancun",
285: Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
286: Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
287: timezones0.put("America/Cancun", tz);
288: timezones0.put("America/Merida", tz);
289: timezones0.put("America/Mexico_City", tz);
290: timezones0.put("America/Monterrey", tz);
291: tz = new SimpleTimeZone(-6000 * 3600, "America/Belize");
292: timezones0.put("America/Belize", tz);
293: timezones0.put("America/Costa_Rica", tz);
294: timezones0.put("America/El_Salvador", tz);
295: timezones0.put("America/Guatemala", tz);
296: timezones0.put("America/Managua", tz);
297: timezones0.put("America/Regina", tz);
298: timezones0.put("America/Swift_Current", tz);
299: timezones0.put("America/Tegucigalpa", tz);
300: timezones0.put("Pacific/Galapagos", tz);
301: tz = new SimpleTimeZone
302: (-6000 * 3600, "CST",
303: Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
304: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
305: timezones0.put("CST", tz);
306: timezones0.put("CST6CDT", tz);
307: timezones0.put("America/Chicago", tz);
308: timezones0.put("America/Indiana/Knox", tz);
309: timezones0.put("America/Indiana/Petersburg", tz);
310: timezones0.put("America/Indiana/Vincennes", tz);
311: timezones0.put("America/Menominee", tz);
312: timezones0.put("America/North_Dakota/Center", tz);
313: timezones0.put("America/North_Dakota/New_Salem", tz);
314: timezones0.put("America/Rainy_River", tz);
315: timezones0.put("America/Rankin_Inlet", tz);
316: timezones0.put("America/Winnipeg", tz);
317: tz = new SimpleTimeZone
318: (-6000 * 3600, "Pacific/Easter",
319: Calendar.OCTOBER, 2, Calendar.SATURDAY, 22000 * 3600,
320: Calendar.MARCH, 2, Calendar.SATURDAY, 22000 * 3600);
321: timezones0.put("Pacific/Easter", tz);
322: tz = new SimpleTimeZone(-5000 * 3600, "EST5");
323: timezones0.put("EST5", tz);
324: timezones0.put("IET", tz);
325: timezones0.put("America/Atikokan", tz);
326: timezones0.put("America/Bogota", tz);
327: timezones0.put("America/Cayman", tz);
328: timezones0.put("America/Eirunepe", tz);
329: timezones0.put("America/Guayaquil", tz);
330: timezones0.put("America/Jamaica", tz);
331: timezones0.put("America/Lima", tz);
332: timezones0.put("America/Panama", tz);
333: timezones0.put("America/Rio_Branco", tz);
334: tz = new SimpleTimeZone
335: (-5000 * 3600, "America/Havana",
336: Calendar.APRIL, 1, Calendar.SUNDAY, 0 * 3600,
337: Calendar.OCTOBER, -1, Calendar.SUNDAY, 1000 * 3600);
338: timezones0.put("America/Havana", tz);
339: tz = new SimpleTimeZone
340: (-5000 * 3600, "America/Grand_Turk",
341: Calendar.APRIL, 1, Calendar.SUNDAY, 0 * 3600,
342: Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
343: timezones0.put("America/Grand_Turk", tz);
344: timezones0.put("America/Port-au-Prince", tz);
345: tz = new SimpleTimeZone
346: (-5000 * 3600, "EST",
347: Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
348: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
349: timezones0.put("EST", tz);
350: timezones0.put("EST5EDT", tz);
351: timezones0.put("America/Detroit", tz);
352: timezones0.put("America/Indiana/Indianapolis", tz);
353: timezones0.put("America/Indiana/Marengo", tz);
354: timezones0.put("America/Indiana/Vevay", tz);
355: timezones0.put("America/Iqaluit", tz);
356: timezones0.put("America/Kentucky/Louisville", tz);
357: timezones0.put("America/Kentucky/Monticello", tz);
358: timezones0.put("America/Montreal", tz);
359: timezones0.put("America/Nassau", tz);
360: timezones0.put("America/New_York", tz);
361: timezones0.put("America/Nipigon", tz);
362: timezones0.put("America/Pangnirtung", tz);
363: timezones0.put("America/Thunder_Bay", tz);
364: timezones0.put("America/Toronto", tz);
365: tz = new SimpleTimeZone
366: (-4000 * 3600, "America/Asuncion",
367: Calendar.OCTOBER, 3, Calendar.SUNDAY, 0 * 3600,
368: Calendar.MARCH, 2, Calendar.SUNDAY, 0 * 3600);
369: timezones0.put("America/Asuncion", tz);
370: tz = new SimpleTimeZone(-4000 * 3600, "PRT");
371: timezones0.put("PRT", tz);
372: timezones0.put("America/Anguilla", tz);
373: timezones0.put("America/Antigua", tz);
374: timezones0.put("America/Aruba", tz);
375: timezones0.put("America/Barbados", tz);
376: timezones0.put("America/Blanc-Sablon", tz);
377: timezones0.put("America/Boa_Vista", tz);
378: timezones0.put("America/Caracas", tz);
379: timezones0.put("America/Curacao", tz);
380: timezones0.put("America/Dominica", tz);
381: timezones0.put("America/Grenada", tz);
382: timezones0.put("America/Guadeloupe", tz);
383: timezones0.put("America/Guyana", tz);
384: timezones0.put("America/La_Paz", tz);
385: timezones0.put("America/Manaus", tz);
386: timezones0.put("America/Martinique", tz);
387: timezones0.put("America/Montserrat", tz);
388: timezones0.put("America/Port_of_Spain", tz);
389: timezones0.put("America/Porto_Velho", tz);
390: timezones0.put("America/Puerto_Rico", tz);
391: timezones0.put("America/Santo_Domingo", tz);
392: timezones0.put("America/St_Kitts", tz);
393: timezones0.put("America/St_Lucia", tz);
394: timezones0.put("America/St_Thomas", tz);
395: timezones0.put("America/St_Vincent", tz);
396: timezones0.put("America/Tortola", tz);
397: tz = new SimpleTimeZone
398: (-4000 * 3600, "America/Campo_Grande",
399: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0 * 3600,
400: Calendar.FEBRUARY, -1, Calendar.SUNDAY, 0 * 3600);
401: timezones0.put("America/Campo_Grande", tz);
402: timezones0.put("America/Cuiaba", tz);
403: tz = new SimpleTimeZone
404: (-4000 * 3600, "America/Goose_Bay",
405: Calendar.MARCH, 2, Calendar.SUNDAY, 60000,
406: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 60000);
407: timezones0.put("America/Goose_Bay", tz);
408: tz = new SimpleTimeZone
409: (-4000 * 3600, "America/Glace_Bay",
410: Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
411: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
412: timezones0.put("America/Glace_Bay", tz);
413: timezones0.put("America/Halifax", tz);
414: timezones0.put("America/Moncton", tz);
415: timezones0.put("America/Thule", tz);
416: timezones0.put("Atlantic/Bermuda", tz);
417: tz = new SimpleTimeZone
418: (-4000 * 3600, "America/Santiago",
419: Calendar.OCTOBER, 9, -Calendar.SUNDAY, 0 * 3600,
420: Calendar.MARCH, 9, -Calendar.SUNDAY, 0 * 3600);
421: timezones0.put("America/Santiago", tz);
422: timezones0.put("Antarctica/Palmer", tz);
423: tz = new SimpleTimeZone
424: (-4000 * 3600, "Atlantic/Stanley",
425: Calendar.SEPTEMBER, 1, Calendar.SUNDAY, 2000 * 3600,
426: Calendar.APRIL, 3, Calendar.SUNDAY, 2000 * 3600);
427: timezones0.put("Atlantic/Stanley", tz);
428: tz = new SimpleTimeZone
429: (-3500 * 3600, "CNT",
430: Calendar.MARCH, 2, Calendar.SUNDAY, 60000,
431: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 60000);
432: timezones0.put("CNT", tz);
433: timezones0.put("America/St_Johns", tz);
434: tz = new SimpleTimeZone
435: (-3000 * 3600, "America/Godthab",
436: Calendar.MARCH, 30, -Calendar.SATURDAY, 22000 * 3600,
437: Calendar.OCTOBER, 30, -Calendar.SATURDAY, 23000 * 3600);
438: timezones0.put("America/Godthab", tz);
439: tz = new SimpleTimeZone
440: (-3000 * 3600, "America/Miquelon",
441: Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600,
442: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 2000 * 3600);
443: timezones0.put("America/Miquelon", tz);
444: tz = new SimpleTimeZone
445: (-3000 * 3600, "America/Montevideo",
446: Calendar.OCTOBER, 1, Calendar.SUNDAY, 2000 * 3600,
447: Calendar.MARCH, 2, Calendar.SUNDAY, 2000 * 3600);
448: timezones0.put("America/Montevideo", tz);
449: tz = new SimpleTimeZone
450: (-3000 * 3600, "America/Sao_Paulo",
451: Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0 * 3600,
452: Calendar.FEBRUARY, -1, Calendar.SUNDAY, 0 * 3600);
453: timezones0.put("America/Sao_Paulo", tz);
454: tz = new SimpleTimeZone(-3000 * 3600, "AGT");
455: timezones0.put("AGT", tz);
456: timezones0.put("America/Araguaina", tz);
457: timezones0.put("America/Argentina/Buenos_Aires", tz);
458: timezones0.put("America/Argentina/Catamarca", tz);
459: timezones0.put("America/Argentina/Cordoba", tz);
460: timezones0.put("America/Argentina/Jujuy", tz);
461: timezones0.put("America/Argentina/La_Rioja", tz);
462: timezones0.put("America/Argentina/Mendoza", tz);
463: timezones0.put("America/Argentina/Rio_Gallegos", tz);
464: timezones0.put("America/Argentina/San_Juan", tz);
465: timezones0.put("America/Argentina/Tucuman", tz);
466: timezones0.put("America/Argentina/Ushuaia", tz);
467: timezones0.put("America/Bahia", tz);
468: timezones0.put("America/Belem", tz);
469: timezones0.put("America/Cayenne", tz);
470: timezones0.put("America/Fortaleza", tz);
471: timezones0.put("America/Maceio", tz);
472: timezones0.put("America/Paramaribo", tz);
473: timezones0.put("America/Recife", tz);
474: timezones0.put("Antarctica/Rothera", tz);
475: tz = new SimpleTimeZone(-2000 * 3600, "America/Noronha");
476: timezones0.put("America/Noronha", tz);
477: timezones0.put("Atlantic/South_Georgia", tz);
478: tz = new SimpleTimeZone
479: (-1000 * 3600, "America/Scoresbysund",
480: Calendar.MARCH, -1, Calendar.SUNDAY, 0 * 3600,
481: Calendar.OCTOBER, -1, Calendar.SUNDAY, 1000 * 3600);
482: timezones0.put("America/Scoresbysund", tz);
483: timezones0.put("Atlantic/Azores", tz);
484: tz = new SimpleTimeZone(-1000 * 3600, "Atlantic/Cape_Verde");
485: timezones0.put("Atlantic/Cape_Verde", tz);
486: tz = new SimpleTimeZone(0 * 3600, "GMT");
487: timezones0.put("GMT", tz);
488: timezones0.put("UTC", tz);
489: timezones0.put("Africa/Abidjan", tz);
490: timezones0.put("Africa/Accra", tz);
491: timezones0.put("Africa/Bamako", tz);
492: timezones0.put("Africa/Banjul", tz);
493: timezones0.put("Africa/Bissau", tz);
494: timezones0.put("Africa/Casablanca", tz);
495: timezones0.put("Africa/Conakry", tz);
496: timezones0.put("Africa/Dakar", tz);
497: timezones0.put("Africa/El_Aaiun", tz);
498: timezones0.put("Africa/Freetown", tz);
499: timezones0.put("Africa/Lome", tz);
500: timezones0.put("Africa/Monrovia", tz);
501: timezones0.put("Africa/Nouakchott", tz);
502: timezones0.put("Africa/Ouagadougou", tz);
503: timezones0.put("Africa/Sao_Tome", tz);
504: timezones0.put("America/Danmarkshavn", tz);
505: timezones0.put("Atlantic/Reykjavik", tz);
506: timezones0.put("Atlantic/St_Helena", tz);
507: tz = new SimpleTimeZone
508: (0 * 3600, "WET",
509: Calendar.MARCH, -1, Calendar.SUNDAY, 1000 * 3600,
510: Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
511: timezones0.put("WET", tz);
512: timezones0.put("Atlantic/Canary", tz);
513: timezones0.put("Atlantic/Faroe", tz);
514: timezones0.put("Atlantic/Madeira", tz);
515: timezones0.put("Europe/Dublin", tz);
516: timezones0.put("Europe/Guernsey", tz);
517: timezones0.put("Europe/Isle_of_Man", tz);
518: timezones0.put("Europe/Jersey", tz);
519: timezones0.put("Europe/Lisbon", tz);
520: timezones0.put("Europe/London", tz);
521: tz = new SimpleTimeZone(1000 * 3600, "Africa/Algiers");
522: timezones0.put("Africa/Algiers", tz);
523: timezones0.put("Africa/Bangui", tz);
524: timezones0.put("Africa/Brazzaville", tz);
525: timezones0.put("Africa/Douala", tz);
526: timezones0.put("Africa/Kinshasa", tz);
527: timezones0.put("Africa/Lagos", tz);
528: timezones0.put("Africa/Libreville", tz);
529: timezones0.put("Africa/Luanda", tz);
530: timezones0.put("Africa/Malabo", tz);
531: timezones0.put("Africa/Ndjamena", tz);
532: timezones0.put("Africa/Niamey", tz);
533: timezones0.put("Africa/Porto-Novo", tz);
534: tz = new SimpleTimeZone
535: (1000 * 3600, "Africa/Windhoek",
536: Calendar.SEPTEMBER, 1, Calendar.SUNDAY, 2000 * 3600,
537: Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600);
538: timezones0.put("Africa/Windhoek", tz);
539: tz = new SimpleTimeZone
540: (1000 * 3600, "CET",
541: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
542: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
543: timezones0.put("CET", tz);
544: timezones0.put("ECT", tz);
545: timezones0.put("MET", tz);
546: timezones0.put("Africa/Ceuta", tz);
547: timezones0.put("Africa/Tunis", tz);
548: timezones0.put("Arctic/Longyearbyen", tz);
549: timezones0.put("Atlantic/Jan_Mayen", tz);
550: timezones0.put("Europe/Amsterdam", tz);
551: timezones0.put("Europe/Andorra", tz);
552: timezones0.put("Europe/Belgrade", tz);
553: timezones0.put("Europe/Berlin", tz);
554: timezones0.put("Europe/Bratislava", tz);
555: timezones0.put("Europe/Brussels", tz);
556: timezones0.put("Europe/Budapest", tz);
557: timezones0.put("Europe/Copenhagen", tz);
558: timezones0.put("Europe/Gibraltar", tz);
559: timezones0.put("Europe/Ljubljana", tz);
560: timezones0.put("Europe/Luxembourg", tz);
561: timezones0.put("Europe/Madrid", tz);
562: timezones0.put("Europe/Malta", tz);
563: timezones0.put("Europe/Monaco", tz);
564: timezones0.put("Europe/Oslo", tz);
565: timezones0.put("Europe/Paris", tz);
566: timezones0.put("Europe/Podgorica", tz);
567: timezones0.put("Europe/Prague", tz);
568: timezones0.put("Europe/Rome", tz);
569: timezones0.put("Europe/San_Marino", tz);
570: timezones0.put("Europe/Sarajevo", tz);
571: timezones0.put("Europe/Skopje", tz);
572: timezones0.put("Europe/Stockholm", tz);
573: timezones0.put("Europe/Tirane", tz);
574: timezones0.put("Europe/Vaduz", tz);
575: timezones0.put("Europe/Vatican", tz);
576: timezones0.put("Europe/Vienna", tz);
577: timezones0.put("Europe/Warsaw", tz);
578: timezones0.put("Europe/Zagreb", tz);
579: timezones0.put("Europe/Zurich", tz);
580: tz = new SimpleTimeZone
581: (2000 * 3600, "ART",
582: Calendar.APRIL, -1, Calendar.FRIDAY, 0 * 3600,
583: Calendar.SEPTEMBER, -1, Calendar.THURSDAY, 24000 * 3600);
584: timezones0.put("ART", tz);
585: timezones0.put("Africa/Cairo", tz);
586: tz = new SimpleTimeZone(2000 * 3600, "CAT");
587: timezones0.put("CAT", tz);
588: timezones0.put("Africa/Blantyre", tz);
589: timezones0.put("Africa/Bujumbura", tz);
590: timezones0.put("Africa/Gaborone", tz);
591: timezones0.put("Africa/Harare", tz);
592: timezones0.put("Africa/Johannesburg", tz);
593: timezones0.put("Africa/Kigali", tz);
594: timezones0.put("Africa/Lubumbashi", tz);
595: timezones0.put("Africa/Lusaka", tz);
596: timezones0.put("Africa/Maputo", tz);
597: timezones0.put("Africa/Maseru", tz);
598: timezones0.put("Africa/Mbabane", tz);
599: timezones0.put("Africa/Tripoli", tz);
600: timezones0.put("Asia/Jerusalem", tz);
601: tz = new SimpleTimeZone
602: (2000 * 3600, "Asia/Amman",
603: Calendar.MARCH, -1, Calendar.THURSDAY, 0 * 3600,
604: Calendar.OCTOBER, -1, Calendar.FRIDAY, 1000 * 3600);
605: timezones0.put("Asia/Amman", tz);
606: tz = new SimpleTimeZone
607: (2000 * 3600, "Asia/Beirut",
608: Calendar.MARCH, -1, Calendar.SUNDAY, 0 * 3600,
609: Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
610: timezones0.put("Asia/Beirut", tz);
611: tz = new SimpleTimeZone
612: (2000 * 3600, "Asia/Damascus",
613: Calendar.APRIL, 1, 0, 0 * 3600,
614: Calendar.OCTOBER, 1, 0, 0 * 3600);
615: timezones0.put("Asia/Damascus", tz);
616: tz = new SimpleTimeZone
617: (2000 * 3600, "Asia/Gaza",
618: Calendar.APRIL, 1, 0, 0 * 3600,
619: Calendar.OCTOBER, 3, Calendar.FRIDAY, 0 * 3600);
620: timezones0.put("Asia/Gaza", tz);
621: tz = new SimpleTimeZone
622: (2000 * 3600, "EET",
623: Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
624: Calendar.OCTOBER, -1, Calendar.SUNDAY, 4000 * 3600);
625: timezones0.put("EET", tz);
626: timezones0.put("Asia/Istanbul", tz);
627: timezones0.put("Asia/Nicosia", tz);
628: timezones0.put("Europe/Athens", tz);
629: timezones0.put("Europe/Bucharest", tz);
630: timezones0.put("Europe/Chisinau", tz);
631: timezones0.put("Europe/Helsinki", tz);
632: timezones0.put("Europe/Istanbul", tz);
633: timezones0.put("Europe/Kiev", tz);
634: timezones0.put("Europe/Mariehamn", tz);
635: timezones0.put("Europe/Nicosia", tz);
636: timezones0.put("Europe/Riga", tz);
637: timezones0.put("Europe/Simferopol", tz);
638: timezones0.put("Europe/Sofia", tz);
639: timezones0.put("Europe/Tallinn", tz);
640: timezones0.put("Europe/Uzhgorod", tz);
641: timezones0.put("Europe/Vilnius", tz);
642: timezones0.put("Europe/Zaporozhye", tz);
643: tz = new SimpleTimeZone
644: (2000 * 3600, "Europe/Kaliningrad",
645: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
646: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
647: timezones0.put("Europe/Kaliningrad", tz);
648: timezones0.put("Europe/Minsk", tz);
649: tz = new SimpleTimeZone
650: (3000 * 3600, "Asia/Baghdad",
651: Calendar.APRIL, 1, 0, 3000 * 3600,
652: Calendar.OCTOBER, 1, 0, 4000 * 3600);
653: timezones0.put("Asia/Baghdad", tz);
654: tz = new SimpleTimeZone
655: (3000 * 3600, "Europe/Moscow",
656: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
657: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
658: timezones0.put("Europe/Moscow", tz);
659: timezones0.put("Europe/Volgograd", tz);
660: tz = new SimpleTimeZone(3000 * 3600, "EAT");
661: timezones0.put("EAT", tz);
662: timezones0.put("Africa/Addis_Ababa", tz);
663: timezones0.put("Africa/Asmara", tz);
664: timezones0.put("Africa/Dar_es_Salaam", tz);
665: timezones0.put("Africa/Djibouti", tz);
666: timezones0.put("Africa/Kampala", tz);
667: timezones0.put("Africa/Khartoum", tz);
668: timezones0.put("Africa/Mogadishu", tz);
669: timezones0.put("Africa/Nairobi", tz);
670: timezones0.put("Antarctica/Syowa", tz);
671: timezones0.put("Asia/Aden", tz);
672: timezones0.put("Asia/Bahrain", tz);
673: timezones0.put("Asia/Kuwait", tz);
674: timezones0.put("Asia/Qatar", tz);
675: timezones0.put("Asia/Riyadh", tz);
676: timezones0.put("Indian/Antananarivo", tz);
677: timezones0.put("Indian/Comoro", tz);
678: timezones0.put("Indian/Mayotte", tz);
679: tz = new SimpleTimeZone(3500 * 3600, "Asia/Tehran");
680: timezones0.put("Asia/Tehran", tz);
681: tz = new SimpleTimeZone
682: (4000 * 3600, "Asia/Baku",
683: Calendar.MARCH, -1, Calendar.SUNDAY, 4000 * 3600,
684: Calendar.OCTOBER, -1, Calendar.SUNDAY, 5000 * 3600);
685: timezones0.put("Asia/Baku", tz);
686: tz = new SimpleTimeZone
687: (4000 * 3600, "Asia/Yerevan",
688: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
689: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
690: timezones0.put("Asia/Yerevan", tz);
691: timezones0.put("Europe/Samara", tz);
692: tz = new SimpleTimeZone(4000 * 3600, "NET");
693: timezones0.put("NET", tz);
694: timezones0.put("Asia/Dubai", tz);
695: timezones0.put("Asia/Muscat", tz);
696: timezones0.put("Asia/Tbilisi", tz);
697: timezones0.put("Indian/Mahe", tz);
698: timezones0.put("Indian/Mauritius", tz);
699: timezones0.put("Indian/Reunion", tz);
700: tz = new SimpleTimeZone(4500 * 3600, "Asia/Kabul");
701: timezones0.put("Asia/Kabul", tz);
702: tz = new SimpleTimeZone
703: (5000 * 3600, "Asia/Yekaterinburg",
704: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
705: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
706: timezones0.put("Asia/Yekaterinburg", tz);
707: tz = new SimpleTimeZone(5000 * 3600, "PLT");
708: timezones0.put("PLT", tz);
709: timezones0.put("Asia/Aqtau", tz);
710: timezones0.put("Asia/Aqtobe", tz);
711: timezones0.put("Asia/Ashgabat", tz);
712: timezones0.put("Asia/Dushanbe", tz);
713: timezones0.put("Asia/Karachi", tz);
714: timezones0.put("Asia/Oral", tz);
715: timezones0.put("Asia/Samarkand", tz);
716: timezones0.put("Asia/Tashkent", tz);
717: timezones0.put("Indian/Kerguelen", tz);
718: timezones0.put("Indian/Maldives", tz);
719: tz = new SimpleTimeZone(5500 * 3600, "BST");
720: timezones0.put("BST", tz);
721: timezones0.put("IST", tz);
722: timezones0.put("Asia/Calcutta", tz);
723: timezones0.put("Asia/Colombo", tz);
724: tz = new SimpleTimeZone(5750 * 3600, "Asia/Katmandu");
725: timezones0.put("Asia/Katmandu", tz);
726: tz = new SimpleTimeZone(6000 * 3600, "Antarctica/Mawson");
727: timezones0.put("Antarctica/Mawson", tz);
728: timezones0.put("Antarctica/Vostok", tz);
729: timezones0.put("Asia/Almaty", tz);
730: timezones0.put("Asia/Bishkek", tz);
731: timezones0.put("Asia/Dhaka", tz);
732: timezones0.put("Asia/Qyzylorda", tz);
733: timezones0.put("Asia/Thimphu", tz);
734: timezones0.put("Indian/Chagos", tz);
735: tz = new SimpleTimeZone
736: (6000 * 3600, "Asia/Novosibirsk",
737: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
738: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
739: timezones0.put("Asia/Novosibirsk", tz);
740: timezones0.put("Asia/Omsk", tz);
741: tz = new SimpleTimeZone(6500 * 3600, "Asia/Rangoon");
742: timezones0.put("Asia/Rangoon", tz);
743: timezones0.put("Indian/Cocos", tz);
744: tz = new SimpleTimeZone(7000 * 3600, "VST");
745: timezones0.put("VST", tz);
746: timezones0.put("Antarctica/Davis", tz);
747: timezones0.put("Asia/Bangkok", tz);
748: timezones0.put("Asia/Jakarta", tz);
749: timezones0.put("Asia/Phnom_Penh", tz);
750: timezones0.put("Asia/Pontianak", tz);
751: timezones0.put("Asia/Saigon", tz);
752: timezones0.put("Asia/Vientiane", tz);
753: timezones0.put("Indian/Christmas", tz);
754: tz = new SimpleTimeZone
755: (7000 * 3600, "Asia/Hovd",
756: Calendar.MARCH, -1, Calendar.SATURDAY, 2000 * 3600,
757: Calendar.SEPTEMBER, -1, Calendar.SATURDAY, 2000 * 3600);
758: timezones0.put("Asia/Hovd", tz);
759: tz = new SimpleTimeZone
760: (7000 * 3600, "Asia/Krasnoyarsk",
761: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
762: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
763: timezones0.put("Asia/Krasnoyarsk", tz);
764: tz = new SimpleTimeZone(8000 * 3600, "CTT");
765: timezones0.put("CTT", tz);
766: timezones0.put("Antarctica/Casey", tz);
767: timezones0.put("Asia/Brunei", tz);
768: timezones0.put("Asia/Chongqing", tz);
769: timezones0.put("Asia/Harbin", tz);
770: timezones0.put("Asia/Hong_Kong", tz);
771: timezones0.put("Asia/Kashgar", tz);
772: timezones0.put("Asia/Kuala_Lumpur", tz);
773: timezones0.put("Asia/Kuching", tz);
774: timezones0.put("Asia/Macau", tz);
775: timezones0.put("Asia/Makassar", tz);
776: timezones0.put("Asia/Manila", tz);
777: timezones0.put("Asia/Shanghai", tz);
778: timezones0.put("Asia/Singapore", tz);
779: timezones0.put("Asia/Taipei", tz);
780: timezones0.put("Asia/Urumqi", tz);
781: timezones0.put("Australia/Perth", tz);
782: tz = new SimpleTimeZone
783: (8000 * 3600, "Asia/Irkutsk",
784: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
785: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
786: timezones0.put("Asia/Irkutsk", tz);
787: tz = new SimpleTimeZone
788: (8000 * 3600, "Asia/Ulaanbaatar",
789: Calendar.MARCH, -1, Calendar.SATURDAY, 2000 * 3600,
790: Calendar.SEPTEMBER, -1, Calendar.SATURDAY, 2000 * 3600);
791: timezones0.put("Asia/Ulaanbaatar", tz);
792: tz = new SimpleTimeZone(8750 * 3600, "Australia/Eucla");
793: timezones0.put("Australia/Eucla", tz);
794: tz = new SimpleTimeZone
795: (9000 * 3600, "Asia/Choibalsan",
796: Calendar.MARCH, -1, Calendar.SATURDAY, 2000 * 3600,
797: Calendar.SEPTEMBER, -1, Calendar.SATURDAY, 2000 * 3600);
798: timezones0.put("Asia/Choibalsan", tz);
799: tz = new SimpleTimeZone(9000 * 3600, "JST");
800: timezones0.put("JST", tz);
801: timezones0.put("Asia/Dili", tz);
802: timezones0.put("Asia/Jayapura", tz);
803: timezones0.put("Asia/Pyongyang", tz);
804: timezones0.put("Asia/Seoul", tz);
805: timezones0.put("Asia/Tokyo", tz);
806: timezones0.put("Pacific/Palau", tz);
807: tz = new SimpleTimeZone
808: (9000 * 3600, "Asia/Yakutsk",
809: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
810: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
811: timezones0.put("Asia/Yakutsk", tz);
812: tz = new SimpleTimeZone
813: (9500 * 3600, "Australia/Adelaide",
814: Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,
815: Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600);
816: timezones0.put("Australia/Adelaide", tz);
817: timezones0.put("Australia/Broken_Hill", tz);
818: tz = new SimpleTimeZone(9500 * 3600, "ACT");
819: timezones0.put("ACT", tz);
820: timezones0.put("Australia/Darwin", tz);
821: tz = new SimpleTimeZone(10000 * 3600, "Antarctica/DumontDUrville");
822: timezones0.put("Antarctica/DumontDUrville", tz);
823: timezones0.put("Australia/Brisbane", tz);
824: timezones0.put("Australia/Lindeman", tz);
825: timezones0.put("Pacific/Guam", tz);
826: timezones0.put("Pacific/Port_Moresby", tz);
827: timezones0.put("Pacific/Saipan", tz);
828: timezones0.put("Pacific/Truk", tz);
829: tz = new SimpleTimeZone
830: (10000 * 3600, "Asia/Sakhalin",
831: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
832: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
833: timezones0.put("Asia/Sakhalin", tz);
834: timezones0.put("Asia/Vladivostok", tz);
835: tz = new SimpleTimeZone
836: (10000 * 3600, "Australia/Currie",
837: Calendar.OCTOBER, 1, Calendar.SUNDAY, 2000 * 3600,
838: Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600);
839: timezones0.put("Australia/Currie", tz);
840: timezones0.put("Australia/Hobart", tz);
841: tz = new SimpleTimeZone
842: (10000 * 3600, "AET",
843: Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,
844: Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600);
845: timezones0.put("AET", tz);
846: timezones0.put("Australia/Melbourne", tz);
847: timezones0.put("Australia/Sydney", tz);
848: tz = new SimpleTimeZone
849: (10500 * 3600, "Australia/Lord_Howe",
850: Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,
851: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600, 500 * 3600);
852: timezones0.put("Australia/Lord_Howe", tz);
853: tz = new SimpleTimeZone
854: (11000 * 3600, "Asia/Magadan",
855: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
856: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
857: timezones0.put("Asia/Magadan", tz);
858: tz = new SimpleTimeZone(11000 * 3600, "SST");
859: timezones0.put("SST", tz);
860: timezones0.put("Pacific/Efate", tz);
861: timezones0.put("Pacific/Guadalcanal", tz);
862: timezones0.put("Pacific/Kosrae", tz);
863: timezones0.put("Pacific/Noumea", tz);
864: timezones0.put("Pacific/Ponape", tz);
865: tz = new SimpleTimeZone(11500 * 3600, "Pacific/Norfolk");
866: timezones0.put("Pacific/Norfolk", tz);
867: tz = new SimpleTimeZone
868: (12000 * 3600, "NST",
869: Calendar.OCTOBER, 1, Calendar.SUNDAY, 2000 * 3600,
870: Calendar.MARCH, 3, Calendar.SUNDAY, 3000 * 3600);
871: timezones0.put("NST", tz);
872: timezones0.put("Antarctica/McMurdo", tz);
873: timezones0.put("Antarctica/South_Pole", tz);
874: timezones0.put("Pacific/Auckland", tz);
875: tz = new SimpleTimeZone
876: (12000 * 3600, "Asia/Anadyr",
877: Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
878: Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
879: timezones0.put("Asia/Anadyr", tz);
880: timezones0.put("Asia/Kamchatka", tz);
881: tz = new SimpleTimeZone(12000 * 3600, "Pacific/Fiji");
882: timezones0.put("Pacific/Fiji", tz);
883: timezones0.put("Pacific/Funafuti", tz);
884: timezones0.put("Pacific/Kwajalein", tz);
885: timezones0.put("Pacific/Majuro", tz);
886: timezones0.put("Pacific/Nauru", tz);
887: timezones0.put("Pacific/Tarawa", tz);
888: timezones0.put("Pacific/Wake", tz);
889: timezones0.put("Pacific/Wallis", tz);
890: tz = new SimpleTimeZone
891: (12750 * 3600, "Pacific/Chatham",
892: Calendar.OCTOBER, 1, Calendar.SUNDAY, 2750 * 3600,
893: Calendar.MARCH, 3, Calendar.SUNDAY, 3750 * 3600);
894: timezones0.put("Pacific/Chatham", tz);
895: tz = new SimpleTimeZone(13000 * 3600, "Pacific/Enderbury");
896: timezones0.put("Pacific/Enderbury", tz);
897: timezones0.put("Pacific/Tongatapu", tz);
898: tz = new SimpleTimeZone(14000 * 3600, "Pacific/Kiritimati");
899: timezones0.put("Pacific/Kiritimati", tz);
900: }
901: return timezones0;
902: }
903:
904:
948: static TimeZone getDefaultTimeZone(String sysTimeZoneId)
949: {
950: String stdName = null;
951: int stdOffs;
952: int dstOffs;
953: try
954: {
955: int idLength = sysTimeZoneId.length();
956:
957: int index = 0;
958: int prevIndex;
959: char c;
960:
961:
962: do
963: c = sysTimeZoneId.charAt(index);
964: while (c != '+' && c != '-' && c != ',' && c != ':'
965: && ! Character.isDigit(c) && c != '\0' && ++index < idLength);
966:
967: if (index >= idLength)
968: return getTimeZoneInternal(sysTimeZoneId);
969:
970: stdName = sysTimeZoneId.substring(0, index);
971: prevIndex = index;
972:
973:
974: do
975: c = sysTimeZoneId.charAt(index++);
976: while ((c == '-' || c == '+' || c == ':' || Character.isDigit(c))
977: && index < idLength);
978: if (index < idLength)
979: index--;
980:
981: {
982: String offset = sysTimeZoneId.substring(prevIndex, index);
983: prevIndex = index;
984:
985: if (offset.charAt(0) == '+' || offset.charAt(0) == '-')
986: stdOffs = parseTime(offset.substring(1));
987: else
988: stdOffs = parseTime(offset);
989:
990: if (offset.charAt(0) == '-')
991: stdOffs = -stdOffs;
992:
993:
994: stdOffs = -stdOffs;
995: }
996:
997:
998: if (index >= idLength)
999: {
1000:
1001: TimeZone tz = getTimeZoneInternal(stdName);
1002: if (tz != null)
1003: if (tz.getRawOffset() == stdOffs)
1004: return tz;
1005:
1006:
1007: return new SimpleTimeZone(stdOffs, stdName);
1008: }
1009:
1010:
1011: do
1012: c = sysTimeZoneId.charAt(index);
1013: while (c != '+' && c != '-' && c != ',' && c != ':'
1014: && ! Character.isDigit(c) && c != '\0' && ++index < idLength);
1015:
1016:
1017: if (index >= idLength)
1018: {
1019:
1020:
1021: TimeZone tz = getTimeZoneInternal(stdName);
1022: if (tz != null)
1023: if (tz.getRawOffset() == stdOffs && tz.useDaylightTime())
1024: return tz;
1025:
1026:
1027: return new SimpleTimeZone(stdOffs, stdName);
1028: }
1029:
1030:
1031: prevIndex = index;
1032: do
1033: c = sysTimeZoneId.charAt(index++);
1034: while ((c == '-' || c == '+' || c == ':' || Character.isDigit(c))
1035: && index < idLength);
1036: if (index < idLength)
1037: index--;
1038:
1039: if (index == prevIndex && (c == ',' || c == ';'))
1040: {
1041:
1042:
1043: dstOffs = stdOffs + 60 * 60 * 1000;
1044: }
1045: else
1046: {
1047: String offset = sysTimeZoneId.substring(prevIndex, index);
1048: prevIndex = index;
1049:
1050: if (offset.charAt(0) == '+' || offset.charAt(0) == '-')
1051: dstOffs = parseTime(offset.substring(1));
1052: else
1053: dstOffs = parseTime(offset);
1054:
1055: if (offset.charAt(0) == '-')
1056: dstOffs = -dstOffs;
1057:
1058:
1059: dstOffs = -dstOffs;
1060: }
1061:
1062:
1063:
1064: if (index >= idLength)
1065: {
1066:
1067: TimeZone tz = getTimeZoneInternal(stdName);
1068: if (tz != null)
1069: if (tz.getRawOffset() == stdOffs && tz.useDaylightTime()
1070: && tz.getDSTSavings() == (dstOffs - stdOffs))
1071: return tz;
1072:
1073: return new SimpleTimeZone(stdOffs, stdName);
1074: }
1075:
1076:
1077: if (sysTimeZoneId.charAt(index) == ','
1078: || sysTimeZoneId.charAt(index) == ';')
1079: {
1080: index++;
1081: int offs = index;
1082: while (sysTimeZoneId.charAt(index) != ','
1083: && sysTimeZoneId.charAt(index) != ';')
1084: index++;
1085: String startTime = sysTimeZoneId.substring(offs, index);
1086: index++;
1087: String endTime = sysTimeZoneId.substring(index);
1088:
1089: index = startTime.indexOf('/');
1090: int startMillis;
1091: int endMillis;
1092: String startDate;
1093: String endDate;
1094: if (index != -1)
1095: {
1096: startDate = startTime.substring(0, index);
1097: startMillis = parseTime(startTime.substring(index + 1));
1098: }
1099: else
1100: {
1101: startDate = startTime;
1102:
1103: startMillis = 2 * 60 * 60 * 1000;
1104: }
1105: index = endTime.indexOf('/');
1106: if (index != -1)
1107: {
1108: endDate = endTime.substring(0, index);
1109: endMillis = parseTime(endTime.substring(index + 1));
1110: }
1111: else
1112: {
1113: endDate = endTime;
1114:
1115: endMillis = 2 * 60 * 60 * 1000;
1116: }
1117:
1118: int[] start = getDateParams(startDate);
1119: int[] end = getDateParams(endDate);
1120: return new SimpleTimeZone(stdOffs, stdName, start[0], start[1],
1121: start[2], startMillis, end[0], end[1],
1122: end[2], endMillis, (dstOffs - stdOffs));
1123: }
1124: }
1125:
1126:
1127: catch (IndexOutOfBoundsException _)
1128: {
1129: }
1130: catch (NumberFormatException _)
1131: {
1132: }
1133:
1134: return null;
1135: }
1136:
1137:
1142: private static int[] getDateParams(String date)
1143: {
1144: int[] dayCount = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
1145: int month;
1146:
1147: if (date.charAt(0) == 'M' || date.charAt(0) == 'm')
1148: {
1149: int day;
1150:
1151:
1152: month = Integer.parseInt(date.substring(1, date.indexOf('.')));
1153: int week = Integer.parseInt(date.substring(date.indexOf('.') + 1,
1154: date.lastIndexOf('.')));
1155: int dayOfWeek = Integer.parseInt(date.substring(date.lastIndexOf('.')
1156: + 1));
1157: if (week == 5)
1158: day = -1;
1159: else
1160:
1161: day = (week - 1) * 7 + 1;
1162:
1163: dayOfWeek++;
1164: month--;
1165: return new int[] { month, day, dayOfWeek };
1166: }
1167:
1168:
1169:
1170: int julianDay;
1171:
1172: if (date.charAt(0) != 'J' || date.charAt(0) != 'j')
1173: {
1174: julianDay = Integer.parseInt(date.substring(1));
1175: julianDay++;
1176:
1177: dayCount = new int[]
1178: {
1179: 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335
1180: };
1181: }
1182: else
1183:
1184: julianDay = Integer.parseInt(date);
1185:
1186: int i = 11;
1187: while (i > 0)
1188: if (dayCount[i] < julianDay)
1189: break;
1190: else
1191: i--;
1192: julianDay -= dayCount[i];
1193: month = i;
1194: return new int[] { month, julianDay, 0 };
1195: }
1196:
1197:
1201: private static int parseTime(String time)
1202: {
1203: int millis = 0;
1204: int i = 0;
1205:
1206: while (i < time.length())
1207: if (time.charAt(i) == ':')
1208: break;
1209: else
1210: i++;
1211: millis = 60 * 60 * 1000 * Integer.parseInt(time.substring(0, i));
1212: if (i >= time.length())
1213: return millis;
1214:
1215: int iprev = ++i;
1216: while (i < time.length())
1217: if (time.charAt(i) == ':')
1218: break;
1219: else
1220: i++;
1221: millis += 60 * 1000 * Integer.parseInt(time.substring(iprev, i));
1222: if (i >= time.length())
1223: return millis;
1224:
1225: millis += 1000 * Integer.parseInt(time.substring(++i));
1226: return millis;
1227: }
1228:
1229:
1241: public abstract int getOffset(int era, int year, int month,
1242: int day, int dayOfWeek, int milliseconds);
1243:
1244:
1252: public int getOffset(long date)
1253: {
1254: return (inDaylightTime(new Date(date))
1255: ? getRawOffset() + getDSTSavings()
1256: : getRawOffset());
1257: }
1258:
1259:
1264: public abstract int getRawOffset();
1265:
1266:
1271: public abstract void setRawOffset(int offsetMillis);
1272:
1273:
1278: public String getID()
1279: {
1280: return ID;
1281: }
1282:
1283:
1289: public void setID(String id)
1290: {
1291: if (id == null)
1292: throw new NullPointerException();
1293:
1294: this.ID = id;
1295: }
1296:
1297:
1305: public final String getDisplayName()
1306: {
1307: return (getDisplayName(false, LONG, Locale.getDefault()));
1308: }
1309:
1310:
1320: public final String getDisplayName(Locale locale)
1321: {
1322: return (getDisplayName(false, LONG, locale));
1323: }
1324:
1325:
1336: public final String getDisplayName(boolean dst, int style)
1337: {
1338: return (getDisplayName(dst, style, Locale.getDefault()));
1339: }
1340:
1341:
1342:
1354: public String getDisplayName(boolean dst, int style, Locale locale)
1355: {
1356: DateFormatSymbols dfs;
1357: try
1358: {
1359: dfs = new DateFormatSymbols(locale);
1360:
1361:
1362: String[][]zoneinfo = dfs.getZoneStrings();
1363: for (int i = 0; i < zoneinfo.length; i++)
1364: {
1365: if (zoneinfo[i][0].equals(getID()))
1366: {
1367: if (!dst)
1368: {
1369: if (style == SHORT)
1370: return (zoneinfo[i][2]);
1371: else
1372: return (zoneinfo[i][1]);
1373: }
1374: else
1375: {
1376: if (style == SHORT)
1377: return (zoneinfo[i][4]);
1378: else
1379: return (zoneinfo[i][3]);
1380: }
1381: }
1382: }
1383: }
1384: catch (MissingResourceException e)
1385: {
1386: }
1387:
1388: return getDefaultDisplayName(dst);
1389: }
1390:
1391: private String getDefaultDisplayName(boolean dst)
1392: {
1393: int offset = getRawOffset();
1394: if (dst && this instanceof SimpleTimeZone)
1395: {
1396:
1397:
1398:
1399: offset += ((SimpleTimeZone) this).getDSTSavings();
1400: }
1401:
1402: StringBuffer sb = new StringBuffer(9);
1403: sb.append("GMT");
1404:
1405: offset = offset / (1000 * 60);
1406: int hours = Math.abs(offset) / 60;
1407: int minutes = Math.abs(offset) % 60;
1408:
1409: if (minutes != 0 || hours != 0)
1410: {
1411: sb.append(offset >= 0 ? '+' : '-');
1412: sb.append((char) ('0' + hours / 10));
1413: sb.append((char) ('0' + hours % 10));
1414: sb.append(':');
1415: sb.append((char) ('0' + minutes / 10));
1416: sb.append((char) ('0' + minutes % 10));
1417: }
1418:
1419: return sb.toString();
1420: }
1421:
1422:
1425: public abstract boolean useDaylightTime();
1426:
1427:
1432: public abstract boolean inDaylightTime(Date date);
1433:
1434:
1445: public int getDSTSavings ()
1446: {
1447: return useDaylightTime () ? 3600000 : 0;
1448: }
1449:
1450:
1456: private static TimeZone getTimeZoneInternal(String ID)
1457: {
1458:
1459: TimeZone tz = null;
1460: TimeZone tznew = null;
1461: for (int pass = 0; pass < 2; pass++)
1462: {
1463: synchronized (TimeZone.class)
1464: {
1465: tz = (TimeZone) timezones().get(ID);
1466: if (tz != null)
1467: {
1468: if (!tz.getID().equals(ID))
1469: {
1470:
1471:
1472: tz = (TimeZone) tz.clone();
1473: tz.setID(ID);
1474:
1475:
1476:
1477: timezones().put(ID, tz);
1478: }
1479: return tz;
1480: }
1481: else if (tznew != null)
1482: {
1483: timezones().put(ID, tznew);
1484: return tznew;
1485: }
1486: }
1487:
1488: if (pass == 1 || zoneinfo_dir == null)
1489: return null;
1490:
1491:
1492:
1493: String zonename = (String) aliases0.get(ID);
1494: if (zonename == null)
1495: zonename = ID;
1496:
1497:
1498: tznew = ZoneInfo.readTZFile (ID, zoneinfo_dir
1499: + File.separatorChar + zonename);
1500: if (tznew == null)
1501: return null;
1502: }
1503:
1504: return null;
1505: }
1506:
1507:
1513: public static TimeZone getTimeZone(String ID)
1514: {
1515:
1516: if (ID.startsWith("GMT") && ID.length() > 3)
1517: {
1518: int pos = 3;
1519: int offset_direction = 1;
1520:
1521: if (ID.charAt(pos) == '-')
1522: {
1523: offset_direction = -1;
1524: pos++;
1525: }
1526: else if (ID.charAt(pos) == '+')
1527: {
1528: pos++;
1529: }
1530:
1531: try
1532: {
1533: int hour, minute;
1534:
1535: String offset_str = ID.substring(pos);
1536: int idx = offset_str.indexOf(":");
1537: if (idx != -1)
1538: {
1539: hour = Integer.parseInt(offset_str.substring(0, idx));
1540: minute = Integer.parseInt(offset_str.substring(idx + 1));
1541: }
1542: else
1543: {
1544: int offset_length = offset_str.length();
1545: if (offset_length <= 2)
1546: {
1547:
1548: hour = Integer.parseInt(offset_str);
1549: minute = 0;
1550: }
1551: else
1552: {
1553:
1554: hour = Integer.parseInt
1555: (offset_str.substring(0, offset_length - 2));
1556: minute = Integer.parseInt
1557: (offset_str.substring(offset_length - 2));
1558: }
1559: }
1560:
1561:
1562: StringBuffer sb = new StringBuffer(9);
1563: sb.append("GMT");
1564:
1565: sb.append(offset_direction >= 0 ? '+' : '-');
1566: sb.append((char) ('0' + hour / 10));
1567: sb.append((char) ('0' + hour % 10));
1568: sb.append(':');
1569: sb.append((char) ('0' + minute / 10));
1570: sb.append((char) ('0' + minute % 10));
1571: ID = sb.toString();
1572:
1573: return new SimpleTimeZone((hour * (60 * 60 * 1000)
1574: + minute * (60 * 1000))
1575: * offset_direction, ID);
1576: }
1577: catch (NumberFormatException e)
1578: {
1579: }
1580: }
1581:
1582: TimeZone tz = getTimeZoneInternal(ID);
1583: if (tz != null)
1584: return tz;
1585:
1586: return new SimpleTimeZone(0, "GMT");
1587: }
1588:
1589:
1597: public static String[] getAvailableIDs(int rawOffset)
1598: {
1599: synchronized (TimeZone.class)
1600: {
1601: HashMap h = timezones();
1602: int count = 0;
1603: if (zoneinfo_dir == null)
1604: {
1605: Iterator iter = h.entrySet().iterator();
1606: while (iter.hasNext())
1607: {
1608:
1609:
1610: Map.Entry entry = (Map.Entry) iter.next();
1611: if (((TimeZone) entry.getValue()).getRawOffset() == rawOffset)
1612: count++;
1613: }
1614:
1615: String[] ids = new String[count];
1616: count = 0;
1617: iter = h.entrySet().iterator();
1618: while (iter.hasNext())
1619: {
1620: Map.Entry entry = (Map.Entry) iter.next();
1621: if (((TimeZone) entry.getValue()).getRawOffset() == rawOffset)
1622: ids[count++] = (String) entry.getKey();
1623: }
1624: return ids;
1625: }
1626: }
1627:
1628: String[] s = getAvailableIDs();
1629: int count = 0;
1630: for (int i = 0; i < s.length; i++)
1631: {
1632: TimeZone t = getTimeZoneInternal(s[i]);
1633: if (t == null || t.getRawOffset() != rawOffset)
1634: s[i] = null;
1635: else
1636: count++;
1637: }
1638: String[] ids = new String[count];
1639: count = 0;
1640: for (int i = 0; i < s.length; i++)
1641: if (s[i] != null)
1642: ids[count++] = s[i];
1643:
1644: return ids;
1645: }
1646:
1647: private static int getAvailableIDs(File d, String prefix, ArrayList list)
1648: {
1649: String[] files = d.list();
1650: int count = files.length;
1651: boolean top = prefix.length() == 0;
1652: list.add (files);
1653: for (int i = 0; i < files.length; i++)
1654: {
1655: if (top
1656: && (files[i].equals("posix")
1657: || files[i].equals("right")
1658: || files[i].endsWith(".tab")
1659: || aliases0.get(files[i]) != null))
1660: {
1661: files[i] = null;
1662: count--;
1663: continue;
1664: }
1665:
1666: File f = new File(d, files[i]);
1667: if (f.isDirectory())
1668: {
1669: count += getAvailableIDs(f, prefix + files[i]
1670: + File.separatorChar, list) - 1;
1671: files[i] = null;
1672: }
1673: else
1674: files[i] = prefix + files[i];
1675: }
1676: return count;
1677: }
1678:
1679:
1683: public static String[] getAvailableIDs()
1684: {
1685: synchronized (TimeZone.class)
1686: {
1687: HashMap h = timezones();
1688: if (zoneinfo_dir == null)
1689: return (String[]) h.keySet().toArray(new String[h.size()]);
1690:
1691: if (availableIDs != null)
1692: {
1693: String[] ids = new String[availableIDs.length];
1694: for (int i = 0; i < availableIDs.length; i++)
1695: ids[i] = availableIDs[i];
1696: return ids;
1697: }
1698:
1699: File d = new File(zoneinfo_dir);
1700: ArrayList list = new ArrayList(30);
1701: int count = getAvailableIDs(d, "", list) + aliases0.size();
1702: availableIDs = new String[count];
1703: String[] ids = new String[count];
1704:
1705: count = 0;
1706: for (int i = 0; i < list.size(); i++)
1707: {
1708: String[] s = (String[]) list.get(i);
1709: for (int j = 0; j < s.length; j++)
1710: if (s[j] != null)
1711: {
1712: availableIDs[count] = s[j];
1713: ids[count++] = s[j];
1714: }
1715: }
1716:
1717: Iterator iter = aliases0.entrySet().iterator();
1718: while (iter.hasNext())
1719: {
1720: Map.Entry entry = (Map.Entry) iter.next();
1721: availableIDs[count] = (String) entry.getKey();
1722: ids[count++] = (String) entry.getKey();
1723: }
1724:
1725: return ids;
1726: }
1727: }
1728:
1729:
1736: public static TimeZone getDefault()
1737: {
1738: return (TimeZone) defaultZone().clone();
1739: }
1740:
1741: public static void setDefault(TimeZone zone)
1742: {
1743:
1744: defaultZone0 = zone;
1745: }
1746:
1747:
1754: public boolean hasSameRules(TimeZone other)
1755: {
1756: return other.getRawOffset() == getRawOffset();
1757: }
1758:
1759:
1763: public Object clone()
1764: {
1765: try
1766: {
1767: return super.clone();
1768: }
1769: catch (CloneNotSupportedException ex)
1770: {
1771: return null;
1772: }
1773: }
1774: }