1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265
|
/* Copyright (C) 1998, 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.text;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* @author Per Bothner <bothner@cygnus.com>
* @date October 24, 1998.
*/
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
* Status: Believed complete and correct.
*/
public class DateFormatSymbols extends Object
implements java.io.Serializable, Cloneable
{
private String[] ampms;
private String[] eras;
private String localPatternChars;
private String[] months;
private String[] shortMonths;
private String[] shortWeekdays;
private String[] weekdays;
private String[][] zoneStrings;
private static final String[] ampmsDefault = {"AM", "PM" };
private static final String[] erasDefault = {"BC", "AD" };
// localPatternCharsDefault is used by SimpleDateFormat.
protected static final String localPatternCharsDefault
= "GyMdkHmsSEDFwWahKz";
private static final String[] monthsDefault = {
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December", ""
};
private static final String[] shortMonthsDefault = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""
};
private static final String[] shortWeekdaysDefault = {
"", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
private static final String[] weekdaysDefault = {
"", "Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"
};
private static String[][] zoneStringsDefault = {
{ "PST", "Pacific Standard Time", "PST",
/**/ "Pacific Daylight Time", "PDT", "San Francisco" },
{ "MST", "Mountain Standard Time", "MST",
/**/ "Mountain Daylight Time", "MDT", "Denver" },
{ "PNT", "Mountain Standard Time", "MST",
/**/ "Mountain Standard Time", "MST", "Phoenix" },
{ "CST", "Central Standard Time", "CST",
/**/ "Central Daylight Time", "CDT", "Chicago" },
{ "EST", "Eastern Standard Time", "EST",
/**/ "Eastern Daylight Time", "EDT", "Boston" },
{ "IET", "Eastern Standard Time", "EST",
/**/ "Eastern Standard Time", "EST", "Indianapolis" },
{ "PRT", "Atlantic Standard Time", "AST",
/**/ "Atlantic Daylight Time", "ADT", "Halifax" },
{ "HST", "Hawaii Standard Time", "HST",
/**/ "Hawaii Daylight Time", "HDT", "Honolulu" },
{ "AST", "Alaska Standard Time", "AST",
/**/ "Alaska Daylight Time", "ADT", "Anchorage" }
};
private final Object safeGetResource (ResourceBundle res,
String key, Object def)
{
if (res != null)
{
try
{
return res.getObject(key);
}
catch (MissingResourceException x)
{
}
}
return def;
}
public DateFormatSymbols (Locale locale)
{
ResourceBundle res;
try
{
res = ResourceBundle.getBundle("gnu.gcj.text.LocaleData", locale);
}
catch (MissingResourceException x)
{
res = null;
}
ampms = (String[]) safeGetResource (res, "ampm", ampmsDefault);
eras = (String[]) safeGetResource (res, "eras", erasDefault);
localPatternChars = (String) safeGetResource (res, "datePatternChars",
localPatternCharsDefault);
months = (String[]) safeGetResource (res, "months", monthsDefault);
shortMonths = (String[]) safeGetResource (res, "shortMonths",
shortMonthsDefault);
shortWeekdays = (String[]) safeGetResource (res, "shortWeekdays",
shortWeekdaysDefault);
weekdays = (String[]) safeGetResource (res, "weekdays", weekdaysDefault);
zoneStrings = (String[][]) safeGetResource (res, "zoneStrings",
zoneStringsDefault);
}
public DateFormatSymbols ()
{
this (Locale.getDefault());
}
public String[] getAmPmStrings()
{
return ampms;
}
public String[] getEras()
{
return eras;
}
public String getLocalPatternChars()
{
return localPatternChars;
}
public String[] getMonths ()
{
return months;
}
public String[] getShortMonths ()
{
return shortMonths;
}
public String[] getShortWeekdays ()
{
return shortWeekdays;
}
public String[] getWeekdays ()
{
return weekdays;
}
public String[] [] getZoneStrings ()
{
return zoneStrings;
}
public void setAmPmStrings (String[] value)
{
ampms = value;
}
public void setEras (String[] value)
{
eras = value;
}
public void setLocalPatternChars (String value)
{
localPatternChars = value;
}
public void setMonths (String[] value)
{
months = value;
}
public void setShortMonths (String[] value)
{
shortMonths = value;
}
public void setShortWeekdays (String[] value)
{
shortWeekdays = value;
}
public void setWeekdays (String[] value)
{
weekdays = value;
}
public void setZoneStrings (String[][] value)
{
zoneStrings = value;
}
/* Does a "deep" equality test - recurses into arrays. */
protected static boolean equals (Object x, Object y)
{
if (x == y)
return true;
if (x == null || y == null)
return false;
if (! (x instanceof Object[]) || ! (y instanceof Object[]))
return x.equals(y);
Object[] xa = (Object[]) x;
Object[] ya = (Object[]) y;
if (xa.length != ya.length)
return false;
for (int i = xa.length; --i >= 0; )
{
if (! equals(xa[i], ya[i]))
return false;
}
return true;
}
private static int hashCode (Object x)
{
if (x == null)
return 0;
if (! (x instanceof Object[]))
return x.hashCode();
Object[] xa = (Object[]) x;
int hash = 0;
for (int i = 0; i < xa.length; i++)
hash = 37 * hashCode(xa[i]);
return hash;
}
public boolean equals (Object obj)
{
if (obj == null || ! (obj instanceof DateFormatSymbols))
return false;
DateFormatSymbols other = (DateFormatSymbols) obj;
return (equals(ampms, other.ampms)
&& equals(eras, other.eras)
&& equals(localPatternChars, other.localPatternChars)
&& equals(months, other.months)
&& equals(shortMonths, other.shortMonths)
&& equals(shortWeekdays, other.shortWeekdays)
&& equals(weekdays, other.weekdays)
&& equals(zoneStrings, other.zoneStrings));
}
public int hashCode ()
{
return (hashCode(ampms)
^ hashCode(eras)
^ hashCode(localPatternChars)
^ hashCode(months)
^ hashCode(shortMonths)
^ hashCode(shortWeekdays)
^ hashCode(weekdays)
^ hashCode(zoneStrings));
}
}
|