author | okutsu |
Tue, 15 Dec 2015 16:42:30 +0900 | |
changeset 34690 | 48ccec8b0e75 |
child 40679 | 5378433ac23f |
permissions | -rw-r--r-- |
34690
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
1 |
/* |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
4 |
* |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
8 |
* |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
13 |
* accompanied this code). |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
14 |
* |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
18 |
* |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
21 |
* questions. |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
22 |
*/ |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
23 |
|
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
24 |
/* |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
25 |
* @test |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
26 |
* @bug 8139572 |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
27 |
* @summary SimpleDateFormat parse month stand-alone format bug |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
28 |
* @compile -encoding utf-8 Bug8139572.java |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
29 |
* @run main Bug8139572 |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
30 |
*/ |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
31 |
import java.text.ParseException; |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
32 |
import java.text.SimpleDateFormat; |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
33 |
import java.util.Calendar; |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
34 |
import java.util.Date; |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
35 |
import java.util.GregorianCalendar; |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
36 |
import java.util.Locale; |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
37 |
|
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
38 |
public class Bug8139572 { |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
39 |
|
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
40 |
private static final Locale RUSSIAN = new Locale("ru"); |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
41 |
private static final Date SEPT12 = new GregorianCalendar(2015, Calendar.SEPTEMBER, 12).getTime(); |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
42 |
|
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
43 |
private static final String[] PATTERNS = { |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
44 |
"L", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
45 |
"dd L", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
46 |
"dd L yy", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
47 |
"dd L yyyy", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
48 |
"LL", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
49 |
"dd LL", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
50 |
"dd LL yy", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
51 |
"dd LL yyyy", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
52 |
"LLL", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
53 |
"dd LLL", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
54 |
"dd LLL yy", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
55 |
"dd LLL yyyy", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
56 |
"LLLL", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
57 |
"dd LLLL", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
58 |
"dd LLLL yy", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
59 |
"dd LLLL yyyy" |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
60 |
}; |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
61 |
|
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
62 |
private static final String[] APPLIED = { |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
63 |
"9", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
64 |
"12 09", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
65 |
"12 09 15", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
66 |
"12 09 2015", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
67 |
"09", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
68 |
"12 09", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
69 |
"12 09 15", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
70 |
"12 09 2015", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
71 |
"сентября", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
72 |
"12 сентября", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
73 |
"12 сентября 15", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
74 |
"12 сентября 2015", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
75 |
"сентября", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
76 |
"12 сентября", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
77 |
"12 сентября 15", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
78 |
"12 сентября 2015" |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
79 |
}; |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
80 |
|
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
81 |
private static final String[] EXPECTED = { |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
82 |
"9", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
83 |
"12 9", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
84 |
"12 9 15", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
85 |
"12 9 2015", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
86 |
"09", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
87 |
"12 09", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
88 |
"12 09 15", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
89 |
"12 09 2015", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
90 |
"сент.", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
91 |
"12 сент.", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
92 |
"12 сент. 15", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
93 |
"12 сент. 2015", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
94 |
"сентябрь", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
95 |
"12 сентябрь", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
96 |
"12 сентябрь 15", |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
97 |
"12 сентябрь 2015" |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
98 |
}; |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
99 |
|
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
100 |
public static void main(String[] args) throws ParseException { |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
101 |
|
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
102 |
for (int i = 0; i < PATTERNS.length; i++) { |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
103 |
SimpleDateFormat fmt = new SimpleDateFormat(PATTERNS[i], RUSSIAN); |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
104 |
Date standAloneDate = fmt.parse(APPLIED[i]); |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
105 |
String str = fmt.format(standAloneDate); |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
106 |
if (!EXPECTED[i].equals(str)) { |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
107 |
throw new RuntimeException("bad result: got '" + str + "', expected '" + EXPECTED[i] + "'"); |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
108 |
} |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
109 |
} |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
110 |
|
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
111 |
SimpleDateFormat fmt = new SimpleDateFormat("", RUSSIAN); |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
112 |
for (int j = 0; j < PATTERNS.length; j++) { |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
113 |
fmt.applyPattern(PATTERNS[j]); |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
114 |
String str = fmt.format(SEPT12); |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
115 |
if (!EXPECTED[j].equals(str)) { |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
116 |
throw new RuntimeException("bad result: got '" + str + "', expected '" + EXPECTED[j] + "'"); |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
117 |
} |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
118 |
} |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
119 |
} |
48ccec8b0e75
8139572: SimpleDateFormat parse month stand-alone format bug
okutsu
parents:
diff
changeset
|
120 |
} |