1 Clazz.declarePackage ("java.text");
\r
2 Clazz.load (["java.text.Format", "java.util.HashMap"], "java.text.DateFormat", ["java.io.InvalidObjectException", "java.lang.IllegalArgumentException", "$.Number", "$.StringBuffer", "java.util.Date", "java.text.DontCareFieldPosition", "$.ParseException", "$.ParsePosition", "java.util.Locale"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.calendar = null;
\r
5 this.numberFormat = null;
\r
6 Clazz.instantialize (this, arguments);
\r
7 }, java.text, "DateFormat", java.text.Format);
\r
8 Clazz.defineMethod (c$, "format",
\r
9 function (obj, toAppendTo, fieldPosition) {
\r
10 if (Clazz.instanceOf (obj, java.util.Date)) return this.format (obj, toAppendTo, fieldPosition);
\r
11 else if (Clazz.instanceOf (obj, Number)) return this.format ( new java.util.Date ((obj).longValue ()), toAppendTo, fieldPosition);
\r
12 else throw new IllegalArgumentException ("Cannot format given Object as a Date");
\r
13 }, "~O,StringBuffer,java.text.FieldPosition");
\r
14 Clazz.defineMethod (c$, "format",
\r
16 return this.format (date, new StringBuffer (), java.text.DontCareFieldPosition.INSTANCE).toString ();
\r
17 }, "java.util.Date");
\r
18 Clazz.defineMethod (c$, "parse",
\r
20 var pos = new java.text.ParsePosition (0);
\r
21 var result = this.parse (source, pos);
\r
22 if (pos.index == 0) throw new java.text.ParseException ("Unparseable date: \"" + source + "\"", pos.errorIndex);
\r
25 Clazz.defineMethod (c$, "parseObject",
\r
26 function (source, pos) {
\r
27 return this.parse (source, pos);
\r
28 }, "~S,java.text.ParsePosition");
\r
29 c$.getTimeInstance = Clazz.defineMethod (c$, "getTimeInstance",
\r
31 return java.text.DateFormat.get (2, 0, 1, java.util.Locale.getDefault ());
\r
33 c$.getTimeInstance = Clazz.defineMethod (c$, "getTimeInstance",
\r
35 return java.text.DateFormat.get (style, 0, 1, java.util.Locale.getDefault ());
\r
37 c$.getTimeInstance = Clazz.defineMethod (c$, "getTimeInstance",
\r
38 function (style, aLocale) {
\r
39 return java.text.DateFormat.get (style, 0, 1, aLocale);
\r
40 }, "~N,java.util.Locale");
\r
41 c$.getDateInstance = Clazz.defineMethod (c$, "getDateInstance",
\r
43 return java.text.DateFormat.get (0, 2, 2, java.util.Locale.getDefault ());
\r
45 c$.getDateInstance = Clazz.defineMethod (c$, "getDateInstance",
\r
47 return java.text.DateFormat.get (0, style, 2, java.util.Locale.getDefault ());
\r
49 c$.getDateInstance = Clazz.defineMethod (c$, "getDateInstance",
\r
50 function (style, aLocale) {
\r
51 return java.text.DateFormat.get (0, style, 2, aLocale);
\r
52 }, "~N,java.util.Locale");
\r
53 c$.getDateTimeInstance = Clazz.defineMethod (c$, "getDateTimeInstance",
\r
55 return java.text.DateFormat.get (2, 2, 3, java.util.Locale.getDefault ());
\r
57 c$.getDateTimeInstance = Clazz.defineMethod (c$, "getDateTimeInstance",
\r
58 function (dateStyle, timeStyle) {
\r
59 return java.text.DateFormat.get (timeStyle, dateStyle, 3, java.util.Locale.getDefault ());
\r
61 c$.getDateTimeInstance = Clazz.defineMethod (c$, "getDateTimeInstance",
\r
62 function (dateStyle, timeStyle, aLocale) {
\r
63 return java.text.DateFormat.get (timeStyle, dateStyle, 3, aLocale);
\r
64 }, "~N,~N,java.util.Locale");
\r
65 c$.getInstance = Clazz.defineMethod (c$, "getInstance",
\r
67 return java.text.DateFormat.getDateTimeInstance (3, 3);
\r
69 Clazz.defineMethod (c$, "setCalendar",
\r
70 function (newCalendar) {
\r
71 this.calendar = newCalendar;
\r
72 }, "java.util.Calendar");
\r
73 Clazz.defineMethod (c$, "getCalendar",
\r
75 return this.calendar;
\r
77 Clazz.defineMethod (c$, "setNumberFormat",
\r
78 function (newNumberFormat) {
\r
79 this.numberFormat = newNumberFormat;
\r
80 }, "java.text.NumberFormat");
\r
81 Clazz.defineMethod (c$, "getNumberFormat",
\r
83 return this.numberFormat;
\r
85 Clazz.defineMethod (c$, "setTimeZone",
\r
87 this.calendar.setTimeZone (zone);
\r
88 }, "java.util.TimeZone");
\r
89 Clazz.defineMethod (c$, "getTimeZone",
\r
91 return this.calendar.getTimeZone ();
\r
93 Clazz.defineMethod (c$, "setLenient",
\r
94 function (lenient) {
\r
95 this.calendar.setLenient (lenient);
\r
97 Clazz.defineMethod (c$, "isLenient",
\r
99 return this.calendar.isLenient ();
\r
101 Clazz.overrideMethod (c$, "hashCode",
\r
103 return this.numberFormat.hashCode ();
\r
105 Clazz.defineMethod (c$, "equals",
\r
107 if (this === obj) return true;
\r
108 if (obj == null || this.getClass () !== obj.getClass ()) return false;
\r
110 return (this.calendar.getFirstDayOfWeek () == other.calendar.getFirstDayOfWeek () && this.calendar.getMinimalDaysInFirstWeek () == other.calendar.getMinimalDaysInFirstWeek () && this.calendar.isLenient () == other.calendar.isLenient () && this.calendar.getTimeZone ().equals (other.calendar.getTimeZone ()) && this.numberFormat.equals (other.numberFormat));
\r
112 Clazz.defineMethod (c$, "clone",
\r
114 var other = Clazz.superCall (this, java.text.DateFormat, "clone", []);
\r
115 other.calendar = this.calendar.clone ();
\r
116 other.numberFormat = this.numberFormat.clone ();
\r
119 c$.get = Clazz.defineMethod (c$, "get",
\r
120 function (timeStyle, dateStyle, flags, loc) {
\r
121 if ((flags & 1) != 0) {
\r
122 if (timeStyle < 0 || timeStyle > 3) {
\r
123 throw new IllegalArgumentException ("Illegal time style " + timeStyle);
\r
126 }if ((flags & 2) != 0) {
\r
127 if (dateStyle < 0 || dateStyle > 3) {
\r
128 throw new IllegalArgumentException ("Illegal date style " + dateStyle);
\r
132 return new java.text.SimpleDateFormat (timeStyle, dateStyle, loc);
\r
134 if (Clazz.exceptionOf (e, java.util.MissingResourceException)) {
\r
135 return new java.text.SimpleDateFormat ("M/d/yy h:mm a");
\r
140 }, "~N,~N,~N,java.util.Locale");
\r
141 Clazz.makeConstructor (c$,
\r
143 Clazz.superConstructor (this, java.text.DateFormat, []);
\r
145 Clazz.pu$h(self.c$);
\r
146 c$ = Clazz.decorateAsClass (function () {
\r
147 this.calendarField = 0;
\r
148 Clazz.instantialize (this, arguments);
\r
149 }, java.text.DateFormat, "Field", java.text.Format.Field);
\r
150 c$.ofCalendarField = Clazz.defineMethod (c$, "ofCalendarField",
\r
152 if (a < 0 || a >= java.text.DateFormat.Field.calendarToFieldMapping.length) {
\r
153 throw new IllegalArgumentException ("Unknown Calendar constant " + a);
\r
154 }return java.text.DateFormat.Field.calendarToFieldMapping[a];
\r
156 Clazz.makeConstructor (c$,
\r
158 Clazz.superConstructor (this, java.text.DateFormat.Field, [a]);
\r
159 this.calendarField = b;
\r
160 if (this.getClass () === java.text.DateFormat.Field) {
\r
161 java.text.DateFormat.Field.$instanceMap.put (a, this);
\r
163 java.text.DateFormat.Field.calendarToFieldMapping[b] = this;
\r
165 Clazz.defineMethod (c$, "getCalendarField",
\r
167 return this.calendarField;
\r
169 Clazz.overrideMethod (c$, "readResolve",
\r
171 if (this.getClass () !== java.text.DateFormat.Field) {
\r
172 throw new java.io.InvalidObjectException ("subclass didn't correctly implement readResolve");
\r
173 }var a = java.text.DateFormat.Field.$instanceMap.get (this.getName ());
\r
177 throw new java.io.InvalidObjectException ("unknown attribute name");
\r
179 c$.$instanceMap = c$.prototype.$instanceMap = new java.util.HashMap (18);
\r
180 c$.calendarToFieldMapping = c$.prototype.calendarToFieldMapping = new Array (17);
\r
181 c$.ERA = c$.prototype.ERA = new java.text.DateFormat.Field ("era", 0);
\r
182 c$.YEAR = c$.prototype.YEAR = new java.text.DateFormat.Field ("year", 1);
\r
183 c$.MONTH = c$.prototype.MONTH = new java.text.DateFormat.Field ("month", 2);
\r
184 c$.DAY_OF_MONTH = c$.prototype.DAY_OF_MONTH = new java.text.DateFormat.Field ("day of month", 5);
\r
185 c$.HOUR_OF_DAY1 = c$.prototype.HOUR_OF_DAY1 = new java.text.DateFormat.Field ("hour of day 1", -1);
\r
186 c$.HOUR_OF_DAY0 = c$.prototype.HOUR_OF_DAY0 = new java.text.DateFormat.Field ("hour of day", 11);
\r
187 c$.MINUTE = c$.prototype.MINUTE = new java.text.DateFormat.Field ("minute", 12);
\r
188 c$.SECOND = c$.prototype.SECOND = new java.text.DateFormat.Field ("second", 13);
\r
189 c$.MILLISECOND = c$.prototype.MILLISECOND = new java.text.DateFormat.Field ("millisecond", 14);
\r
190 c$.DAY_OF_WEEK = c$.prototype.DAY_OF_WEEK = new java.text.DateFormat.Field ("day of week", 7);
\r
191 c$.DAY_OF_YEAR = c$.prototype.DAY_OF_YEAR = new java.text.DateFormat.Field ("day of year", 6);
\r
192 c$.DAY_OF_WEEK_IN_MONTH = c$.prototype.DAY_OF_WEEK_IN_MONTH = new java.text.DateFormat.Field ("day of week in month", 8);
\r
193 c$.WEEK_OF_YEAR = c$.prototype.WEEK_OF_YEAR = new java.text.DateFormat.Field ("week of year", 3);
\r
194 c$.WEEK_OF_MONTH = c$.prototype.WEEK_OF_MONTH = new java.text.DateFormat.Field ("week of month", 4);
\r
195 c$.AM_PM = c$.prototype.AM_PM = new java.text.DateFormat.Field ("am pm", 9);
\r
196 c$.HOUR1 = c$.prototype.HOUR1 = new java.text.DateFormat.Field ("hour 1", -1);
\r
197 c$.HOUR0 = c$.prototype.HOUR0 = new java.text.DateFormat.Field ("hour", 10);
\r
198 c$.TIME_ZONE = c$.prototype.TIME_ZONE = new java.text.DateFormat.Field ("time zone", -1);
\r
200 Clazz.defineStatics (c$,
\r
205 "HOUR_OF_DAY1_FIELD", 4,
\r
206 "HOUR_OF_DAY0_FIELD", 5,
\r
209 "MILLISECOND_FIELD", 8,
\r
210 "DAY_OF_WEEK_FIELD", 9,
\r
211 "DAY_OF_YEAR_FIELD", 10,
\r
212 "DAY_OF_WEEK_IN_MONTH_FIELD", 11,
\r
213 "WEEK_OF_YEAR_FIELD", 12,
\r
214 "WEEK_OF_MONTH_FIELD", 13,
\r
218 "TIMEZONE_FIELD", 17,
\r