636N/A/*
2362N/A * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
636N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
636N/A *
636N/A * This code is free software; you can redistribute it and/or modify it
636N/A * under the terms of the GNU General Public License version 2 only, as
636N/A * published by the Free Software Foundation.
636N/A *
636N/A * This code is distributed in the hope that it will be useful, but WITHOUT
636N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
636N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
636N/A * version 2 for more details (a copy is included in the LICENSE file that
636N/A * accompanied this code).
636N/A *
636N/A * You should have received a copy of the GNU General Public License version
636N/A * 2 along with this work; if not, write to the Free Software Foundation,
636N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
636N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
636N/A */
636N/A
636N/A/*
636N/A * @test
636N/A * @bug 6645292
636N/A * @summary Make sure to parse a DST time zone name with which the
636N/A * last DST rule doesn't observe DST.
636N/A */
636N/A
636N/Aimport java.text.*;
636N/Aimport java.util.*;
636N/Aimport static java.util.Calendar.*;
636N/A
636N/Apublic class Bug6645292 {
636N/A public static void main(String[] args) {
636N/A Locale loc = Locale.getDefault();
636N/A TimeZone zone = TimeZone.getDefault();
636N/A try {
636N/A Locale.setDefault(Locale.US);
636N/A // Use "Asia/Shanghai" with an old time stamp rather than
636N/A // "Australia/Perth" because if Perth decides to obserb DST
636N/A // permanently, that decision will make this test case
636N/A // useless. There's the same risk with China, though.
636N/A TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
636N/A Calendar cal = Calendar.getInstance();
636N/A cal.clear();
636N/A cal.set(1986, JUNE, 1);
636N/A Date d1 = cal.getTime();
636N/A SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzzz");
636N/A String s = df.format(d1);
636N/A Date d2 = null;
636N/A try {
636N/A d2 = df.parse(s);
636N/A } catch (Exception e) {
636N/A throw new RuntimeException(e);
636N/A }
636N/A if (!d1.equals(d2)) {
636N/A throw new RuntimeException("d1 (" + d1 + ") != d2 (" + d2 + ")");
636N/A }
636N/A } finally {
636N/A Locale.setDefault(loc);
636N/A TimeZone.setDefault(zone);
636N/A }
636N/A }
636N/A}