]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/icu/dev/eclipse/plugins/com.ibm.icu.base/src/com/ibm/icu/text/DateFormatSymbols.java
go
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / icu / dev / eclipse / plugins / com.ibm.icu.base / src / com / ibm / icu / text / DateFormatSymbols.java
1 /*\r
2  *******************************************************************************\r
3  * Copyright (C) 1996-2008, International Business Machines Corporation and    *\r
4  * others. All Rights Reserved.                                                *\r
5  *******************************************************************************\r
6  */\r
7 \r
8 package com.ibm.icu.text;\r
9 \r
10 import java.io.Serializable;\r
11 import java.util.Locale;\r
12 \r
13 import com.ibm.icu.util.ULocale;\r
14 \r
15 /**\r
16  * <code>DateFormatSymbols</code> is a public class for encapsulating\r
17  * localizable date-time formatting data, such as the names of the\r
18  * months, the names of the days of the week, and the time zone data.\r
19  * <code>DateFormat</code> and <code>SimpleDateFormat</code> both use\r
20  * <code>DateFormatSymbols</code> to encapsulate this information.\r
21  *\r
22  * <p>\r
23  * Typically you shouldn't use <code>DateFormatSymbols</code> directly.\r
24  * Rather, you are encouraged to create a date-time formatter with the\r
25  * <code>DateFormat</code> class's factory methods: <code>getTimeInstance</code>,\r
26  * <code>getDateInstance</code>, or <code>getDateTimeInstance</code>.\r
27  * These methods automatically create a <code>DateFormatSymbols</code> for\r
28  * the formatter so that you don't have to. After the\r
29  * formatter is created, you may modify its format pattern using the\r
30  * <code>setPattern</code> method. For more information about\r
31  * creating formatters using <code>DateFormat</code>'s factory methods,\r
32  * see {@link DateFormat}.\r
33  *\r
34  * <p>\r
35  * If you decide to create a date-time formatter with a specific\r
36  * format pattern for a specific locale, you can do so with:\r
37  * <blockquote>\r
38  * <pre>\r
39  * new SimpleDateFormat(aPattern, new DateFormatSymbols(aLocale)).\r
40  * </pre>\r
41  * </blockquote>\r
42  *\r
43  * <p>\r
44  * <code>DateFormatSymbols</code> objects are clonable. When you obtain\r
45  * a <code>DateFormatSymbols</code> object, feel free to modify the\r
46  * date-time formatting data. For instance, you can replace the localized\r
47  * date-time format pattern characters with the ones that you feel easy\r
48  * to remember. Or you can change the representative cities\r
49  * to your favorite ones.\r
50  *\r
51  * <p>\r
52  * New <code>DateFormatSymbols</code> subclasses may be added to support\r
53  * <code>SimpleDateFormat</code> for date-time formatting for additional locales.\r
54 \r
55  * @see          DateFormat\r
56  * @see          SimpleDateFormat\r
57  * @see          com.ibm.icu.util.SimpleTimeZone\r
58  * @author       Chen-Lieh Huang\r
59  * @stable ICU 2.0\r
60  */\r
61 public class DateFormatSymbols implements Serializable, Cloneable {\r
62     private static final long serialVersionUID = 1;\r
63         \r
64     /** @internal */\r
65     public java.text.DateFormatSymbols dfs;\r
66         \r
67     /** @internal */\r
68     public DateFormatSymbols(java.text.DateFormatSymbols delegate) {\r
69         this.dfs = delegate;\r
70     }\r
71         \r
72     /**\r
73      * Construct a DateFormatSymbols object by loading format data from\r
74      * resources for the default locale.\r
75      *\r
76      * @throws  java.util.MissingResourceException\r
77      *          if the resources for the default locale cannot be\r
78      *          found or cannot be loaded.\r
79      * @stable ICU 2.0\r
80      */\r
81     public DateFormatSymbols() {\r
82         this(new java.text.DateFormatSymbols());\r
83     }\r
84 \r
85     /**\r
86      * Construct a DateFormatSymbols object by loading format data from\r
87      * resources for the given locale.\r
88      *\r
89      * @throws  java.util.MissingResourceException\r
90      *          if the resources for the specified locale cannot be\r
91      *          found or cannot be loaded.\r
92      * @stable ICU 2.0\r
93      */\r
94     public DateFormatSymbols(Locale locale) {\r
95         this(new java.text.DateFormatSymbols(locale));\r
96     }\r
97         \r
98     /**\r
99      * Construct a DateFormatSymbols object by loading format data from\r
100      * resources for the given ulocale.\r
101      *\r
102      * @throws  java.util.MissingResourceException\r
103      *          if the resources for the specified locale cannot be\r
104      *          found or cannot be loaded.\r
105      * @stable ICU 3.2\r
106      */\r
107     public DateFormatSymbols(ULocale locale) {\r
108         this(new java.text.DateFormatSymbols(locale.toLocale()));\r
109     }\r
110 \r
111     /**\r
112      * Gets era strings. For example: "AD" and "BC".\r
113      * @return the era strings.\r
114      * @stable ICU 2.0\r
115      */\r
116     public String[] getEras() {\r
117         return dfs.getEras();\r
118     }\r
119 \r
120     /**\r
121      * Sets era strings. For example: "AD" and "BC".\r
122      * @param newEras the new era strings.\r
123      * @stable ICU 2.0\r
124      */\r
125     public void setEras(String[] newEras) {\r
126         dfs.setEras(newEras);\r
127     }\r
128 \r
129     /**\r
130      * Gets month strings. For example: "January", "February", etc.\r
131      * @return the month strings.\r
132      * @stable ICU 2.0\r
133      */\r
134     public String[] getMonths() {\r
135         return dfs.getMonths();\r
136     }\r
137 \r
138     /**\r
139      * Sets month strings. For example: "January", "February", etc.\r
140      * @param newMonths the new month strings.\r
141      * @stable ICU 2.0\r
142      */\r
143     public void setMonths(String[] newMonths) {\r
144         dfs.setMonths(newMonths);\r
145     }\r
146             \r
147     /**\r
148      * Gets short month strings. For example: "Jan", "Feb", etc.\r
149      * @return the short month strings.\r
150      * @stable ICU 2.0\r
151      */\r
152     public String[] getShortMonths() {\r
153         return dfs.getShortMonths();\r
154     }\r
155 \r
156     /**\r
157      * Sets short month strings. For example: "Jan", "Feb", etc.\r
158      * @param newShortMonths the new short month strings.\r
159      * @stable ICU 2.0\r
160      */\r
161     public void setShortMonths(String[] newShortMonths) {\r
162         dfs.setShortMonths(newShortMonths);\r
163     }\r
164 \r
165     /**\r
166      * Gets weekday strings. For example: "Sunday", "Monday", etc.\r
167      * @return the weekday strings. Use <code>Calendar.SUNDAY</code>,\r
168      * <code>Calendar.MONDAY</code>, etc. to index the result array.\r
169      * @stable ICU 2.0\r
170      */\r
171     public String[] getWeekdays() {\r
172         return dfs.getWeekdays();\r
173     }\r
174 \r
175     /**\r
176      * Sets weekday strings. For example: "Sunday", "Monday", etc.\r
177      * @param newWeekdays the new weekday strings. The array should\r
178      * be indexed by <code>Calendar.SUNDAY</code>,\r
179      * <code>Calendar.MONDAY</code>, etc.\r
180      * @stable ICU 2.0\r
181      */\r
182     public void setWeekdays(String[] newWeekdays) {\r
183         dfs.setWeekdays(newWeekdays);\r
184     }\r
185 \r
186     /**\r
187      * Gets short weekday strings. For example: "Sun", "Mon", etc.\r
188      * @return the short weekday strings. Use <code>Calendar.SUNDAY</code>,\r
189      * <code>Calendar.MONDAY</code>, etc. to index the result array.\r
190      * @stable ICU 2.0\r
191      */\r
192     public String[] getShortWeekdays() {\r
193         return dfs.getShortWeekdays();\r
194     }\r
195 \r
196     /**\r
197      * Sets short weekday strings. For example: "Sun", "Mon", etc.\r
198      * @param newShortWeekdays the new short weekday strings. The array should\r
199      * be indexed by <code>Calendar.SUNDAY</code>,\r
200      * <code>Calendar.MONDAY</code>, etc.\r
201      * @stable ICU 2.0\r
202      */\r
203     public void setShortWeekdays(String[] newShortWeekdays) {\r
204         dfs.setShortWeekdays(newShortWeekdays);\r
205     }\r
206 \r
207     /**\r
208      * Gets ampm strings. For example: "AM" and "PM".\r
209      * @return the weekday strings.\r
210      * @stable ICU 2.0\r
211      */\r
212     public String[] getAmPmStrings() {\r
213         return dfs.getAmPmStrings();\r
214     }\r
215 \r
216     /**\r
217      * Sets ampm strings. For example: "AM" and "PM".\r
218      * @param newAmpms the new ampm strings.\r
219      * @stable ICU 2.0\r
220      */\r
221     public void setAmPmStrings(String[] newAmpms) {\r
222         dfs.setAmPmStrings(newAmpms);\r
223     }\r
224 \r
225     /**\r
226      * Gets timezone strings.\r
227      * @return the timezone strings.\r
228      * @stable ICU 2.0\r
229      */\r
230     public String[][] getZoneStrings() {\r
231         return dfs.getZoneStrings();\r
232     }\r
233 \r
234     /**\r
235      * Sets timezone strings.\r
236      * @param newZoneStrings the new timezone strings.\r
237      * @stable ICU 2.0\r
238      */\r
239     public void setZoneStrings(String[][] newZoneStrings) {\r
240         dfs.setZoneStrings(newZoneStrings);\r
241     }\r
242 \r
243     /**\r
244      * Gets localized date-time pattern characters. For example: 'u', 't', etc.\r
245      * @return the localized date-time pattern characters.\r
246      * @stable ICU 2.0\r
247      */\r
248     public String getLocalPatternChars() {\r
249         return dfs.getLocalPatternChars();\r
250     }\r
251 \r
252     /**\r
253      * Sets localized date-time pattern characters. For example: 'u', 't', etc.\r
254      * @param newLocalPatternChars the new localized date-time\r
255      * pattern characters.\r
256      * @stable ICU 2.0\r
257      */\r
258     public void setLocalPatternChars(String newLocalPatternChars) {\r
259         dfs.setLocalPatternChars(newLocalPatternChars);\r
260     }\r
261 \r
262     /**\r
263      * Return a string suitable for debugging.\r
264      * @return a string suitable for debugging\r
265      * @stable ICU 3.4.2\r
266      */\r
267     public String toString() {\r
268         return dfs.toString();\r
269     }\r
270         \r
271     /**\r
272      * Return a clone of this DateFormatSymbols.\r
273      * @return a clone of this DateFormatSymbols\r
274      * @stable ICU 3.4.2\r
275      */\r
276     public Object clone() {\r
277         return new DateFormatSymbols((java.text.DateFormatSymbols)dfs.clone());\r
278     }\r
279 \r
280     /**\r
281      * Return true if rhs is a DateFormatSymbols and has the same symbols as this.\r
282      * @return true if rhs equals this\r
283      * @stable ICU 3.4.2\r
284      */\r
285     public boolean equals(Object rhs) {\r
286         try {\r
287             return dfs.equals(((DateFormatSymbols)rhs).dfs);\r
288         }\r
289         catch (Exception e) {\r
290             return false;\r
291         }\r
292     }\r
293         \r
294     /**\r
295      * Return a hashCode.\r
296      * @return a hashCode\r
297      * @stable ICU 3.4.2\r
298      */\r
299     public int hashCode() {\r
300         return dfs.hashCode();\r
301     }\r
302 }\r