*
* 4/21/98 - make smarter, so the test works if the ext resources
* are present or not.
*/
public void TestDisplayName() {
TimeZone zone = TimeZone.getTimeZone("PST");
String name = zone.getDisplayName(Locale.ENGLISH);
logln("PST->" + name);
// dlf - we now (3.4.1) return generic time
if (!name.equals("Pacific Time"))
errln("Fail: Expected \"Pacific Time\", got " + name +
" for " + zone);
//*****************************************************************
// THE FOLLOWING LINES MUST BE UPDATED IF THE LOCALE DATA CHANGES
// THE FOLLOWING LINES MUST BE UPDATED IF THE LOCALE DATA CHANGES
// THE FOLLOWING LINES MUST BE UPDATED IF THE LOCALE DATA CHANGES
//*****************************************************************
// todo: check to see whether we can test for all of pst, pdt, pt
Object[] DATA = {
Boolean.FALSE, new Integer(TimeZone.SHORT), "PST",
Boolean.TRUE, new Integer(TimeZone.SHORT), "PDT",
Boolean.FALSE, new Integer(TimeZone.LONG), "Pacific Standard Time",
Boolean.TRUE, new Integer(TimeZone.LONG), "Pacific Daylight Time",
};
for (int i=0; i<DATA.length; i+=3) {
name = zone.getDisplayName(((Boolean)DATA[i]).booleanValue(),
((Integer)DATA[i+1]).intValue(),
Locale.ENGLISH);
if (!name.equals(DATA[i+2]))
errln("Fail: Expected " + DATA[i+2] + "; got " + name);
}
// Make sure that we don't display the DST name by constructing a fake
// PST zone that has DST all year long.
// dlf - this test is no longer relevant, we display generic time now
// so the behavior of the timezone doesn't matter
SimpleTimeZone zone2 = new SimpleTimeZone(0, "PST");
zone2.setStartRule(Calendar.JANUARY, 1, 0);
zone2.setEndRule(Calendar.DECEMBER, 31, 86399999);
logln("Modified PST inDaylightTime->" + zone2.inDaylightTime(new Date()));
name = zone2.getDisplayName(Locale.ENGLISH);
logln("Modified PST->" + name);
if (!name.equals("Pacific Time"))
errln("Fail: Expected \"Pacific Time\"");
// Make sure we get the default display format for Locales
// with no display name data.
Locale mt_MT = new Locale("mt", "MT");
name = zone.getDisplayName(mt_MT);
//*****************************************************************
// THE FOLLOWING LINE MUST BE UPDATED IF THE LOCALE DATA CHANGES
// THE FOLLOWING LINE MUST BE UPDATED IF THE LOCALE DATA CHANGES
// THE FOLLOWING LINE MUST BE UPDATED IF THE LOCALE DATA CHANGES
//*****************************************************************