blob: e011128cd3941133aead9ec9f3a57602dc503438 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/*
25 *@test
26 *@bug 4848242
27 *@summary Make sure that MET time zone is not misinterpreted in euro locales.
28 * Display the MET and MEST TZ human-readable name in all euro locales.
29 */
30
31import java.util.Locale;
32import java.util.TimeZone;
33import java.text.DateFormatSymbols;
34
35public class Bug4848242 {
36
37 public static void main(String[] args) {
38 getTzInfo("de", "DE");
39 getTzInfo("es", "ES");
40 getTzInfo("fr", "FR");
41 getTzInfo("it", "IT");
42 getTzInfo("sv", "SV");
43 }
44
45 static void getTzInfo(String langName, String locName)
46 {
47 Locale tzLocale = new Locale(langName, locName);
48 TimeZone euroTz = TimeZone.getTimeZone("MET");
49
50 System.out.println("Locale is " + langName + "_" + locName);
51
52 if ( euroTz.getID().equalsIgnoreCase("GMT") ) {
53 // if we don't have a timezone and default back to GMT
54 throw new RuntimeException("Error: no time zone found");
55 }
56
57 // get the timezone info
58 System.out.println(euroTz.getDisplayName(false, TimeZone.SHORT, tzLocale));
59 if(!euroTz.getDisplayName(false, TimeZone.SHORT, tzLocale).equals("MET"))
60 throw new RuntimeException("Timezone name is incorrect (should be MET)\n");
61 System.out.println(euroTz.getDisplayName(false, TimeZone.LONG, tzLocale));
62
63 System.out.println(euroTz.getDisplayName(true, TimeZone.SHORT, tzLocale));
64 if(!euroTz.getDisplayName(true, TimeZone.SHORT, tzLocale).equals("MEST"))
65 throw new RuntimeException("Summer timezone name is incorrect (should be MEST)\n");
66 System.out.println(euroTz.getDisplayName(true, TimeZone.LONG, tzLocale) + "\n");
67
68 }
69
70}