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