70 |
|
|
71 |
/* These constants need to have these exact values. They |
/* These constants need to have these exact values. They |
72 |
* correspond to index positions within the localPatternChars |
* correspond to index positions within the localPatternChars |
73 |
* string for a given locale. For example, the US locale uses |
* string for a given locale. Each locale may specify its |
74 |
* the string "GyMdkHmsSEDFwWahKz", where 'G' is the character |
* own character for a particular field, but the position |
75 |
* for era, 'y' for year, and so on down to 'z' for time zone. |
* of these characters must correspond to an appropriate field |
76 |
|
* number (as listed below), in order for their meaning to |
77 |
|
* be determined. For example, the US locale uses |
78 |
|
* the string "GyMdkHmsSEDFwWahKzYeugAZ", where 'G' is the character |
79 |
|
* for era, 'y' for year, and so on down to 'Z' for time zone. |
80 |
*/ |
*/ |
81 |
|
/** |
82 |
|
* Represents the position of the era |
83 |
|
* pattern character in the array of |
84 |
|
* localized pattern characters. |
85 |
|
* For example, 'AD' is an era used |
86 |
|
* in the Gregorian calendar system. |
87 |
|
* In the U.S. locale, this is 'G'. |
88 |
|
*/ |
89 |
public static final int ERA_FIELD = 0; |
public static final int ERA_FIELD = 0; |
90 |
|
/** |
91 |
|
* Represents the position of the year |
92 |
|
* pattern character in the array of |
93 |
|
* localized pattern characters. |
94 |
|
* In the U.S. locale, this is 'y'. |
95 |
|
*/ |
96 |
public static final int YEAR_FIELD = 1; |
public static final int YEAR_FIELD = 1; |
97 |
|
/** |
98 |
|
* Represents the position of the month |
99 |
|
* pattern character in the array of |
100 |
|
* localized pattern characters. |
101 |
|
* In the U.S. locale, this is 'M'. |
102 |
|
*/ |
103 |
public static final int MONTH_FIELD = 2; |
public static final int MONTH_FIELD = 2; |
104 |
|
/** |
105 |
|
* Represents the position of the date |
106 |
|
* or day of the month pattern character |
107 |
|
* in the array of localized pattern |
108 |
|
* characters. In the U.S. locale, |
109 |
|
* this is 'd'. |
110 |
|
*/ |
111 |
public static final int DATE_FIELD = 3; |
public static final int DATE_FIELD = 3; |
112 |
|
/** |
113 |
|
* Represents the position of the 24 |
114 |
|
* hour pattern character in the array of |
115 |
|
* localized pattern characters. |
116 |
|
* In the U.S. locale, this is 'k'. |
117 |
|
* This field numbers hours from 1 to 24. |
118 |
|
*/ |
119 |
public static final int HOUR_OF_DAY1_FIELD = 4; |
public static final int HOUR_OF_DAY1_FIELD = 4; |
120 |
|
/** |
121 |
|
* Represents the position of the 24 |
122 |
|
* hour pattern character in the array of |
123 |
|
* localized pattern characters. |
124 |
|
* In the U.S. locale, this is 'H'. |
125 |
|
* This field numbers hours from 0 to 23. |
126 |
|
*/ |
127 |
public static final int HOUR_OF_DAY0_FIELD = 5; |
public static final int HOUR_OF_DAY0_FIELD = 5; |
128 |
|
/** |
129 |
|
* Represents the position of the minute |
130 |
|
* pattern character in the array of |
131 |
|
* localized pattern characters. |
132 |
|
* In the U.S. locale, this is 'm'. |
133 |
|
*/ |
134 |
public static final int MINUTE_FIELD = 6; |
public static final int MINUTE_FIELD = 6; |
135 |
|
/** |
136 |
|
* Represents the position of the second |
137 |
|
* pattern character in the array of |
138 |
|
* localized pattern characters. |
139 |
|
* In the U.S. locale, this is 's'. |
140 |
|
*/ |
141 |
public static final int SECOND_FIELD = 7; |
public static final int SECOND_FIELD = 7; |
142 |
|
/** |
143 |
|
* Represents the position of the millisecond |
144 |
|
* pattern character in the array of |
145 |
|
* localized pattern characters. |
146 |
|
* In the U.S. locale, this is 'S'. |
147 |
|
*/ |
148 |
public static final int MILLISECOND_FIELD = 8; |
public static final int MILLISECOND_FIELD = 8; |
149 |
|
/** |
150 |
|
* Represents the position of the day of the |
151 |
|
* week pattern character in the array of |
152 |
|
* localized pattern characters. |
153 |
|
* In the U.S. locale, this is 'E'. |
154 |
|
*/ |
155 |
public static final int DAY_OF_WEEK_FIELD = 9; |
public static final int DAY_OF_WEEK_FIELD = 9; |
156 |
|
/** |
157 |
|
* Represents the position of the day of the |
158 |
|
* year pattern character in the array of |
159 |
|
* localized pattern characters. |
160 |
|
* In the U.S. locale, this is 'D'. |
161 |
|
*/ |
162 |
public static final int DAY_OF_YEAR_FIELD = 10; |
public static final int DAY_OF_YEAR_FIELD = 10; |
163 |
|
/** |
164 |
|
* Represents the position of the day of the |
165 |
|
* week in the month pattern character in the |
166 |
|
* array of localized pattern characters. |
167 |
|
* In the U.S. locale, this is 'F'. |
168 |
|
*/ |
169 |
public static final int DAY_OF_WEEK_IN_MONTH_FIELD = 11; |
public static final int DAY_OF_WEEK_IN_MONTH_FIELD = 11; |
170 |
|
/** |
171 |
|
* Represents the position of the week of the |
172 |
|
* year pattern character in the array of |
173 |
|
* localized pattern characters. |
174 |
|
* In the U.S. locale, this is 'w'. |
175 |
|
*/ |
176 |
public static final int WEEK_OF_YEAR_FIELD = 12; |
public static final int WEEK_OF_YEAR_FIELD = 12; |
177 |
|
/** |
178 |
|
* Represents the position of the week of the |
179 |
|
* month pattern character in the array of |
180 |
|
* localized pattern characters. |
181 |
|
* In the U.S. locale, this is 'W'. |
182 |
|
*/ |
183 |
public static final int WEEK_OF_MONTH_FIELD = 13; |
public static final int WEEK_OF_MONTH_FIELD = 13; |
184 |
|
/** |
185 |
|
* Represents the position of the am/pm |
186 |
|
* pattern character in the array of |
187 |
|
* localized pattern characters. |
188 |
|
* In the U.S. locale, this is 'a'. |
189 |
|
*/ |
190 |
public static final int AM_PM_FIELD = 14; |
public static final int AM_PM_FIELD = 14; |
191 |
|
/** |
192 |
|
* Represents the position of the 12 |
193 |
|
* hour pattern character in the array of |
194 |
|
* localized pattern characters. |
195 |
|
* In the U.S. locale, this is 'h'. |
196 |
|
* This field numbers hours from 1 to 12. |
197 |
|
*/ |
198 |
public static final int HOUR1_FIELD = 15; |
public static final int HOUR1_FIELD = 15; |
199 |
|
/** |
200 |
|
* Represents the position of the 12 |
201 |
|
* hour pattern character in the array of |
202 |
|
* localized pattern characters. |
203 |
|
* In the U.S. locale, this is 'K'. |
204 |
|
* This field numbers hours from 0 to 11. |
205 |
|
*/ |
206 |
public static final int HOUR0_FIELD = 16; |
public static final int HOUR0_FIELD = 16; |
207 |
|
/** |
208 |
|
* Represents the position of the generic |
209 |
|
* timezone pattern character in the array of |
210 |
|
* localized pattern characters. |
211 |
|
* In the U.S. locale, this is 'z'. |
212 |
|
*/ |
213 |
public static final int TIMEZONE_FIELD = 17; |
public static final int TIMEZONE_FIELD = 17; |
214 |
|
/** |
215 |
|
* Represents the position of the ISO year |
216 |
|
* pattern character in the array of |
217 |
|
* localized pattern characters. |
218 |
|
* In the U.S. locale, this is 'Y'. |
219 |
|
* This is a GNU extension in accordance with |
220 |
|
* the CLDR data used. This value may |
221 |
|
* differ from the normal year value. |
222 |
|
*/ |
223 |
|
public static final int ISO_YEAR_FIELD = 18; |
224 |
|
/** |
225 |
|
* Represents the position of the localized |
226 |
|
* day of the week pattern character in the |
227 |
|
* array of localized pattern characters. |
228 |
|
* In the U.S. locale, this is 'e'. |
229 |
|
* This is a GNU extension in accordance with |
230 |
|
* the CLDR data used. This value only |
231 |
|
* differs from the day of the week with |
232 |
|
* numeric formatting, in which case the |
233 |
|
* locale's first day of the week is used. |
234 |
|
*/ |
235 |
|
public static final int LOCALIZED_DAY_OF_WEEK_FIELD = 19; |
236 |
|
/** |
237 |
|
* Represents the position of the extended year |
238 |
|
* pattern character in the array of |
239 |
|
* localized pattern characters. |
240 |
|
* In the U.S. locale, this is 'u'. |
241 |
|
* This is a GNU extension in accordance with |
242 |
|
* the CLDR data used. This value modifies |
243 |
|
* the year value, so as to incorporate the era. |
244 |
|
* For example, in the Gregorian calendar system, |
245 |
|
* the extended year is negative instead of being |
246 |
|
* marked as BC. |
247 |
|
*/ |
248 |
|
public static final int EXTENDED_YEAR_FIELD = 20; |
249 |
|
/** |
250 |
|
* Represents the position of the modified Julian |
251 |
|
* day pattern character in the array of |
252 |
|
* localized pattern characters. |
253 |
|
* In the U.S. locale, this is 'g'. |
254 |
|
* This is a GNU extension in accordance with |
255 |
|
* the CLDR data used. This value differs |
256 |
|
* from the standard Julian day in that days |
257 |
|
* are marked from midnight onwards rather than |
258 |
|
* noon, and the local time zone affects the value. |
259 |
|
* In simple terms, it can be thought of as all |
260 |
|
* the date fields represented as a single number. |
261 |
|
*/ |
262 |
|
public static final int MODIFIED_JULIAN_DAY_FIELD = 21; |
263 |
|
/** |
264 |
|
* Represents the position of the millisecond |
265 |
|
* in the day pattern character in the array of |
266 |
|
* localized pattern characters. |
267 |
|
* In the U.S. locale, this is 'A'. |
268 |
|
* This is a GNU extension in accordance with |
269 |
|
* the CLDR data used. This value represents |
270 |
|
* all the time fields (excluding the time zone) |
271 |
|
* numerically, giving the number of milliseconds |
272 |
|
* into the day (e.g. 10 in the morning would |
273 |
|
* be 10 * 60 * 60 * 1000). Any daylight savings |
274 |
|
* offset also affects this value. |
275 |
|
*/ |
276 |
|
public static final int MILLISECOND_IN_DAY_FIELD = 22; |
277 |
|
/** |
278 |
|
* Represents the position of the RFC822 |
279 |
|
* timezone pattern character in the array of |
280 |
|
* localized pattern characters. |
281 |
|
* In the U.S. locale, this is 'Z'. |
282 |
|
* This is a GNU extension in accordance with |
283 |
|
* the CLDR data used. The value is the offset |
284 |
|
* of the current time from GMT e.g. -0500 would |
285 |
|
* be five hours prior to GMT. |
286 |
|
*/ |
287 |
|
public static final int RFC822_TIMEZONE_FIELD = 23; |
288 |
|
|
289 |
public static class Field extends Format.Field |
public static class Field extends Format.Field |
290 |
{ |
{ |
328 |
= new Field("hour0", Calendar.HOUR); |
= new Field("hour0", Calendar.HOUR); |
329 |
public static final DateFormat.Field TIME_ZONE |
public static final DateFormat.Field TIME_ZONE |
330 |
= new Field("timezone", Calendar.ZONE_OFFSET); |
= new Field("timezone", Calendar.ZONE_OFFSET); |
331 |
|
public static final DateFormat.Field ISO_YEAR |
332 |
|
= new Field("iso year", Calendar.YEAR); |
333 |
|
public static final DateFormat.Field LOCALIZED_DAY_OF_WEEK |
334 |
|
= new Field("localized day of week", Calendar.DAY_OF_WEEK); |
335 |
|
public static final DateFormat.Field EXTENDED_YEAR |
336 |
|
= new Field("extended year", Calendar.YEAR); |
337 |
|
public static final DateFormat.Field MODIFIED_JULIAN_DAY |
338 |
|
= new Field("julian day", -1); |
339 |
|
public static final DateFormat.Field MILLISECOND_IN_DAY |
340 |
|
= new Field("millisecond in day", -1); |
341 |
|
public static final DateFormat.Field RFC822_TIME_ZONE |
342 |
|
= new Field("rfc822 timezone", Calendar.ZONE_OFFSET); |
343 |
|
|
344 |
static final DateFormat.Field[] allFields = |
static final DateFormat.Field[] allFields = |
345 |
{ |
{ |
346 |
ERA, YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY1, |
ERA, YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY1, |
347 |
HOUR_OF_DAY0, MINUTE, SECOND, MILLISECOND, |
HOUR_OF_DAY0, MINUTE, SECOND, MILLISECOND, |
348 |
DAY_OF_WEEK, DAY_OF_YEAR, DAY_OF_WEEK_IN_MONTH, |
DAY_OF_WEEK, DAY_OF_YEAR, DAY_OF_WEEK_IN_MONTH, |
349 |
WEEK_OF_YEAR, WEEK_OF_MONTH, AM_PM, HOUR1, HOUR0, |
WEEK_OF_YEAR, WEEK_OF_MONTH, AM_PM, HOUR1, HOUR0, |
350 |
TIME_ZONE |
TIME_ZONE, ISO_YEAR, LOCALIZED_DAY_OF_WEEK, |
351 |
|
EXTENDED_YEAR, MODIFIED_JULIAN_DAY, MILLISECOND_IN_DAY, |
352 |
|
RFC822_TIME_ZONE |
353 |
}; |
}; |
354 |
|
|
355 |
// For deserialization |
// For deserialization |