author | peytoia |
Mon, 08 Sep 2008 13:31:45 +0900 | |
changeset 1312 | 880799c54c4d |
child 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
1312
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
1 |
/* |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
2 |
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
4 |
* |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
8 |
* |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
13 |
* accompanied this code). |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
14 |
* |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
18 |
* |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
21 |
* have any questions. |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
22 |
*/ |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
23 |
|
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
24 |
/* |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
25 |
* @test |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
26 |
* @bug 6645292 |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
27 |
* @summary Make sure to parse a DST time zone name with which the |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
28 |
* last DST rule doesn't observe DST. |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
29 |
*/ |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
30 |
|
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
31 |
import java.text.*; |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
32 |
import java.util.*; |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
33 |
import static java.util.Calendar.*; |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
34 |
|
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
35 |
public class Bug6645292 { |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
36 |
public static void main(String[] args) { |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
37 |
Locale loc = Locale.getDefault(); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
38 |
TimeZone zone = TimeZone.getDefault(); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
39 |
try { |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
40 |
Locale.setDefault(Locale.US); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
41 |
// Use "Asia/Shanghai" with an old time stamp rather than |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
42 |
// "Australia/Perth" because if Perth decides to obserb DST |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
43 |
// permanently, that decision will make this test case |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
44 |
// useless. There's the same risk with China, though. |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
45 |
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
46 |
Calendar cal = Calendar.getInstance(); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
47 |
cal.clear(); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
48 |
cal.set(1986, JUNE, 1); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
49 |
Date d1 = cal.getTime(); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
50 |
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzzz"); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
51 |
String s = df.format(d1); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
52 |
Date d2 = null; |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
53 |
try { |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
54 |
d2 = df.parse(s); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
55 |
} catch (Exception e) { |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
56 |
throw new RuntimeException(e); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
57 |
} |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
58 |
if (!d1.equals(d2)) { |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
59 |
throw new RuntimeException("d1 (" + d1 + ") != d2 (" + d2 + ")"); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
60 |
} |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
61 |
} finally { |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
62 |
Locale.setDefault(loc); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
63 |
TimeZone.setDefault(zone); |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
64 |
} |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
65 |
} |
880799c54c4d
6645292: [Fmt-Da] Timezone Western Summer Time (Australia) is parsed incorrectly
peytoia
parents:
diff
changeset
|
66 |
} |