Path: blob/master/test/jdk/sun/util/resources/cldr/Bug8134384.java
41153 views
/*1* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 8134384 8234347 823654826* @summary Tests CLDR TimeZoneNames has English names for all tzids27* @run main/othervm -Djava.locale.providers=CLDR Bug813438428*/2930import java.text.*;31import java.time.*;32import java.util.*;3334public class Bug8134384 {35public static void main(String [] args) {36TimeZone original = TimeZone.getDefault();3738try {39for (String tz : TimeZone.getAvailableIDs() ) {40TimeZone.setDefault(TimeZone.getTimeZone(tz));41// Summer solstice42String date1 = Date.from(Instant.parse("2015-06-21T00:00:00.00Z")).toString();43testParse(Locale.ENGLISH, date1, tz);44testParse(Locale.US, date1, tz);45// Winter solstice46String date2 = Date.from(Instant.parse("2015-12-22T00:00:00.00Z")).toString();47testParse(Locale.ENGLISH, date2, tz);48testParse(Locale.US, date2, tz);49}50} finally {51TimeZone.setDefault(original);52}53}5455private static void testParse(Locale locale, String date, String tz) {56try {57new SimpleDateFormat("EEE MMM d hh:mm:ss z yyyy", locale).parse(date);58System.out.println(String.format(Locale.ENGLISH, "OK parsing '%s' in locale '%s', tz: %s", date, locale, tz));59} catch (ParseException pe) {60throw new RuntimeException(String.format(Locale.ENGLISH, "ERROR parsing '%s' in locale '%s', tz: %s: %s", date, locale, tz, pe.toString()));61}62}63}646566