1 Clazz.declarePackage ("java.util");
2 Clazz.load (null, "java.util.TimeZone", ["java.lang.InternalError", "$.NullPointerException", "java.util.Date", "$.HashMap"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 Clazz.instantialize (this, arguments);
6 }, java.util, "TimeZone", null, Cloneable);
7 Clazz.makeConstructor (c$,
10 Clazz.defineMethod (c$, "getOffset",
12 if (this.inDaylightTime ( new java.util.Date (date))) {
13 return this.getRawOffset () + this.getDSTSavings ();
14 }return this.getRawOffset ();
16 Clazz.defineMethod (c$, "getOffsets",
17 function (date, offsets) {
18 var rawoffset = this.getRawOffset ();
20 if (this.inDaylightTime ( new java.util.Date (date))) {
21 dstoffset = this.getDSTSavings ();
22 }if (offsets != null) {
23 offsets[0] = rawoffset;
24 offsets[1] = dstoffset;
25 }return rawoffset + dstoffset;
27 Clazz.defineMethod (c$, "getID",
31 Clazz.defineMethod (c$, "setID",
34 throw new NullPointerException ();
37 Clazz.defineMethod (c$, "getDSTSavings",
39 if (this.useDaylightTime ()) {
43 c$.getTimeZone = Clazz.defineMethod (c$, "getTimeZone",
45 return java.util.TimeZone.getTimeZone (ID, true);
47 c$.getTimeZone = Clazz.defineMethod (c$, "getTimeZone",
48 function (ID, fallback) {
50 tz = java.util.TimeZone.parseCustomTimeZone (ID);
51 if (tz == null && fallback) {
52 tz = new jssun.util.calendar.ZoneInfo ("GMT", 0);
55 c$.getAvailableIDs = Clazz.defineMethod (c$, "getAvailableIDs",
56 function (rawOffset) {
59 c$.getAvailableIDs = Clazz.defineMethod (c$, "getAvailableIDs",
63 c$.getDefault = Clazz.defineMethod (c$, "getDefault",
65 return java.util.TimeZone.getDefaultRef ().clone ();
67 c$.getDefaultRef = Clazz.defineMethod (c$, "getDefaultRef",
69 if (java.util.TimeZone.defaultTimeZone == null) {
70 var ms = java.util.TimeZone.getTimeZoneOffsetMillis ();
71 var gmtOffsetID = java.util.TimeZone.getGMTID (ms);
72 java.util.TimeZone.defaultTimeZone = java.util.TimeZone.getTimeZone (gmtOffsetID, true);
73 java.util.TimeZone.addToCache (gmtOffsetID, new jssun.util.calendar.ZoneInfo (gmtOffsetID, ms));
74 }return java.util.TimeZone.defaultTimeZone;
76 c$.getTimeZoneOffsetMillis = Clazz.defineMethod (c$, "getTimeZoneOffsetMillis",
79 return -(new Date()).getTimezoneOffset() * 60000;
81 c$.setDefault = Clazz.defineMethod (c$, "setDefault",
83 }, "java.util.TimeZone");
84 Clazz.defineMethod (c$, "hasSameRules",
86 return other != null && this.getRawOffset () == other.getRawOffset () && this.useDaylightTime () == other.useDaylightTime ();
87 }, "java.util.TimeZone");
88 Clazz.defineMethod (c$, "clone",
91 var other = Clazz.superCall (this, java.util.TimeZone, "clone", []);
95 if (Clazz.exceptionOf (e, CloneNotSupportedException)) {
96 throw new InternalError ();
102 c$.parseCustomTimeZone = Clazz.defineMethod (c$, "parseCustomTimeZone",
104 if ((id.length) < (5) || id.indexOf ("GMT") != 0) {
107 var neghrmin = java.util.TimeZone.getOffsetHHMM (id);
108 if (neghrmin == null) return null;
109 var gmtOffset = (neghrmin[0]) * (neghrmin[1] * 60 + neghrmin[2]) * 60 * 1000;
110 var gmtID = java.util.TimeZone.getGMTID (gmtOffset);
111 zi = new jssun.util.calendar.ZoneInfo ();
112 if (gmtOffset == 0) {
114 zi.setRawOffsetReally (gmtOffset);
118 c$.getOffsetHHMM = Clazz.defineMethod (c$, "getOffsetHHMM",
121 var length = id.length;
122 var negative = false;
123 var c = id.charAt (index++);
126 } else if (c != '+') {
132 while (index < length) {
133 c = id.charAt (index++);
135 if (countDelim > 0) {
144 }if (c < '0' || c > '9') {
146 }num = num * 10 + (c.charCodeAt (0) - 48);
149 if (index != length) {
151 }if (countDelim == 0) {
156 hours = Clazz.doubleToInt (num / 100);
161 }}if (hours > 23 || num > 59) {
163 }return Clazz.newIntArray (-1, [(negative ? -1 : 1), hours, num]);
165 c$.getGMTID = Clazz.defineMethod (c$, "getGMTID",
166 function (gmtOffset) {
167 var isNegative = (gmtOffset < 0);
168 if (isNegative) gmtOffset = -gmtOffset;
169 gmtOffset = Clazz.doubleToInt (gmtOffset / 60000);
170 var hours = Clazz.doubleToInt (gmtOffset / 60);
171 var min = gmtOffset - hours * 60;
172 var NN = "00" + hours;
173 NN = NN.substring (NN.length - 2);
175 MM = MM.substring (MM.length - 2);
176 return "GMT" + (isNegative ? "-" : "") + NN;
178 c$.getCustomTimeZone = Clazz.defineMethod (c$, "getCustomTimeZone",
179 function (originalId, gmtOffset) {
180 var id = java.util.TimeZone.toCustomID (gmtOffset);
181 var zi = java.util.TimeZone.getFromCache (id);
183 zi = new jssun.util.calendar.ZoneInfo (id, gmtOffset);
184 zi = java.util.TimeZone.addToCache (id, zi);
185 if (originalId != null && !id.equals (originalId)) {
186 zi = java.util.TimeZone.addToCache (originalId, zi);
187 }}return zi.clone ();
189 c$.toCustomID = Clazz.defineMethod (c$, "toCustomID",
190 function (gmtOffset) {
192 var offset = Clazz.doubleToInt (gmtOffset / 60000);
198 }var hh = Clazz.doubleToInt (offset / 60);
199 var mm = offset % 60;
200 var buf = Clazz.newCharArray (-1, ['G', 'M', 'T', sign, '0', '0', ':', '0', '0']);
202 buf[4] = String.fromCharCode ((buf[4]).charCodeAt (0) + (Clazz.doubleToInt (hh / 10)));
203 }buf[5] = String.fromCharCode ((buf[5]).charCodeAt (0) + (hh % 10));
205 buf[7] = String.fromCharCode ((buf[7]).charCodeAt (0) + (Clazz.doubleToInt (mm / 10)));
206 buf[8] = String.fromCharCode ((buf[8]).charCodeAt (0) + (mm % 10));
207 }return String.instantialize (buf);
209 c$.getFromCache = Clazz.defineMethod (c$, "getFromCache",
211 if (java.util.TimeZone.zoneInfoObjects == null) {
213 }return java.util.TimeZone.zoneInfoObjects.get (id);
215 c$.addToCache = Clazz.defineMethod (c$, "addToCache",
217 if (java.util.TimeZone.zoneInfoObjects == null) {
218 java.util.TimeZone.zoneInfoObjects = new java.util.HashMap ();
220 var zone = java.util.TimeZone.zoneInfoObjects.get (id);
223 }}java.util.TimeZone.zoneInfoObjects.put (id, zi);
225 }, "~S,jssun.util.calendar.ZoneInfo");
226 Clazz.defineStatics (c$,
230 "defaultTimeZone", null,
233 "zoneInfoObjects", null);