2 *******************************************************************************
\r
3 * Copyright (C) 1996-2008, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 *******************************************************************************
\r
8 package com.ibm.icu.text;
\r
10 import java.io.Serializable;
\r
11 import java.util.Locale;
\r
13 import com.ibm.icu.util.ULocale;
\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
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
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
39 * new SimpleDateFormat(aPattern, new DateFormatSymbols(aLocale)).
\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
52 * New <code>DateFormatSymbols</code> subclasses may be added to support
\r
53 * <code>SimpleDateFormat</code> for date-time formatting for additional locales.
\r
56 * @see SimpleDateFormat
\r
57 * @see com.ibm.icu.util.SimpleTimeZone
\r
58 * @author Chen-Lieh Huang
\r
61 public class DateFormatSymbols implements Serializable, Cloneable {
\r
62 private static final long serialVersionUID = 1;
\r
65 public java.text.DateFormatSymbols dfs;
\r
68 public DateFormatSymbols(java.text.DateFormatSymbols delegate) {
\r
69 this.dfs = delegate;
\r
73 * Construct a DateFormatSymbols object by loading format data from
\r
74 * resources for the default locale.
\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
81 public DateFormatSymbols() {
\r
82 this(new java.text.DateFormatSymbols());
\r
86 * Construct a DateFormatSymbols object by loading format data from
\r
87 * resources for the given locale.
\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
94 public DateFormatSymbols(Locale locale) {
\r
95 this(new java.text.DateFormatSymbols(locale));
\r
99 * Construct a DateFormatSymbols object by loading format data from
\r
100 * resources for the given ulocale.
\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
107 public DateFormatSymbols(ULocale locale) {
\r
108 this(new java.text.DateFormatSymbols(locale.toLocale()));
\r
112 * Gets era strings. For example: "AD" and "BC".
\r
113 * @return the era strings.
\r
116 public String[] getEras() {
\r
117 return dfs.getEras();
\r
121 * Sets era strings. For example: "AD" and "BC".
\r
122 * @param newEras the new era strings.
\r
125 public void setEras(String[] newEras) {
\r
126 dfs.setEras(newEras);
\r
130 * Gets month strings. For example: "January", "February", etc.
\r
131 * @return the month strings.
\r
134 public String[] getMonths() {
\r
135 return dfs.getMonths();
\r
139 * Sets month strings. For example: "January", "February", etc.
\r
140 * @param newMonths the new month strings.
\r
143 public void setMonths(String[] newMonths) {
\r
144 dfs.setMonths(newMonths);
\r
148 * Gets short month strings. For example: "Jan", "Feb", etc.
\r
149 * @return the short month strings.
\r
152 public String[] getShortMonths() {
\r
153 return dfs.getShortMonths();
\r
157 * Sets short month strings. For example: "Jan", "Feb", etc.
\r
158 * @param newShortMonths the new short month strings.
\r
161 public void setShortMonths(String[] newShortMonths) {
\r
162 dfs.setShortMonths(newShortMonths);
\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
171 public String[] getWeekdays() {
\r
172 return dfs.getWeekdays();
\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
182 public void setWeekdays(String[] newWeekdays) {
\r
183 dfs.setWeekdays(newWeekdays);
\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
192 public String[] getShortWeekdays() {
\r
193 return dfs.getShortWeekdays();
\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
203 public void setShortWeekdays(String[] newShortWeekdays) {
\r
204 dfs.setShortWeekdays(newShortWeekdays);
\r
208 * Gets ampm strings. For example: "AM" and "PM".
\r
209 * @return the weekday strings.
\r
212 public String[] getAmPmStrings() {
\r
213 return dfs.getAmPmStrings();
\r
217 * Sets ampm strings. For example: "AM" and "PM".
\r
218 * @param newAmpms the new ampm strings.
\r
221 public void setAmPmStrings(String[] newAmpms) {
\r
222 dfs.setAmPmStrings(newAmpms);
\r
226 * Gets timezone strings.
\r
227 * @return the timezone strings.
\r
230 public String[][] getZoneStrings() {
\r
231 return dfs.getZoneStrings();
\r
235 * Sets timezone strings.
\r
236 * @param newZoneStrings the new timezone strings.
\r
239 public void setZoneStrings(String[][] newZoneStrings) {
\r
240 dfs.setZoneStrings(newZoneStrings);
\r
244 * Gets localized date-time pattern characters. For example: 'u', 't', etc.
\r
245 * @return the localized date-time pattern characters.
\r
248 public String getLocalPatternChars() {
\r
249 return dfs.getLocalPatternChars();
\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
258 public void setLocalPatternChars(String newLocalPatternChars) {
\r
259 dfs.setLocalPatternChars(newLocalPatternChars);
\r
263 * Return a string suitable for debugging.
\r
264 * @return a string suitable for debugging
\r
265 * @stable ICU 3.4.2
\r
267 public String toString() {
\r
268 return dfs.toString();
\r
272 * Return a clone of this DateFormatSymbols.
\r
273 * @return a clone of this DateFormatSymbols
\r
274 * @stable ICU 3.4.2
\r
276 public Object clone() {
\r
277 return new DateFormatSymbols((java.text.DateFormatSymbols)dfs.clone());
\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
285 public boolean equals(Object rhs) {
\r
287 return dfs.equals(((DateFormatSymbols)rhs).dfs);
\r
289 catch (Exception e) {
\r
295 * Return a hashCode.
\r
296 * @return a hashCode
\r
297 * @stable ICU 3.4.2
\r
299 public int hashCode() {
\r
300 return dfs.hashCode();
\r