author | ohair |
Tue, 25 May 2010 15:58:33 -0700 | |
changeset 5506 | 202f599c92aa |
parent 1838 | 3bd2ef9cbefb |
child 31263 | a81a0af34ca0 |
permissions | -rw-r--r-- |
1829
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. |
1829
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
4 |
* |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
8 |
* |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
13 |
* accompanied this code). |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
14 |
* |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
1829
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
22 |
*/ |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
23 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
24 |
/** |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
25 |
* @test |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
26 |
* @bug 6683975 |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
27 |
* @summary Make sure that date is formatted correctlyin th locale. |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
28 |
*/ |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
29 |
import java.text.*; |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
30 |
import java.util.*; |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
31 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
32 |
public class Bug6683975 { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
33 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
34 |
private static boolean err = false; |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
35 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
36 |
private static Locale th = new Locale("th", ""); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
37 |
private static Locale th_TH = new Locale("th", "TH"); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
38 |
private static String expected_th[] = { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
39 |
"\u0e27\u0e31\u0e19\u0e2d\u0e31\u0e07\u0e04\u0e32\u0e23\u0e17\u0e35\u0e48 30 \u0e01\u0e31\u0e19\u0e22\u0e32\u0e22\u0e19 \u0e04.\u0e28. 2008, 8 \u0e19\u0e32\u0e2c\u0e34\u0e01\u0e32 0 \u0e19\u0e32\u0e17\u0e35 00 \u0e27\u0e34\u0e19\u0e32\u0e17\u0e35", // 0: FULL |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
40 |
"30 \u0e01\u0e31\u0e19\u0e22\u0e32\u0e22\u0e19 2008, 8 \u0e19\u0e32\u0e2c\u0e34\u0e01\u0e32 0 \u0e19\u0e32\u0e17\u0e35", // 1: LONG |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
41 |
"30 \u0e01.\u0e22. 2008, 8:00:00", // 2: MEDIUM |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
42 |
"30/9/2008, 8:00 \u0e19.", // 3: SHORT |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
43 |
}; |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
44 |
private static String expected_th_TH[] = { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
45 |
"\u0e27\u0e31\u0e19\u0e2d\u0e31\u0e07\u0e04\u0e32\u0e23\u0e17\u0e35\u0e48 30 \u0e01\u0e31\u0e19\u0e22\u0e32\u0e22\u0e19 \u0e1e.\u0e28. 2551, 8 \u0e19\u0e32\u0e2c\u0e34\u0e01\u0e32 0 \u0e19\u0e32\u0e17\u0e35 00 \u0e27\u0e34\u0e19\u0e32\u0e17\u0e35", // 0: FULL |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
46 |
"30 \u0e01\u0e31\u0e19\u0e22\u0e32\u0e22\u0e19 2551, 8 \u0e19\u0e32\u0e2c\u0e34\u0e01\u0e32 0 \u0e19\u0e32\u0e17\u0e35", // 1: LONG |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
47 |
"30 \u0e01.\u0e22. 2551, 8:00:00", // 2: MEDIUM |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
48 |
"30/9/2551, 8:00 \u0e19." // 3: SHORT |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
49 |
}; |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
50 |
private static String stylePattern[] = { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
51 |
"FULL", "LONG", "MEDIUM", "SHORT" |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
52 |
}; |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
53 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
54 |
private static void test(int style) { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
55 |
DateFormat df_th = DateFormat.getDateTimeInstance(style, style, th); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
56 |
DateFormat df_th_TH = DateFormat.getDateTimeInstance(style, style, th_TH); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
57 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
58 |
String str_th = ((SimpleDateFormat)df_th).toPattern(); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
59 |
String str_th_TH = ((SimpleDateFormat)df_th_TH).toPattern(); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
60 |
if (!str_th.equals(str_th_TH)) { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
61 |
err = true; |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
62 |
System.err.println("Error: Pattern for th locale should be the same as pattern for th_TH locale. (" + stylePattern[style] + ")"); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
63 |
System.err.println("\tth: " + str_th); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
64 |
System.err.println("\tth_TH: " + str_th_TH); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
65 |
} |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
66 |
|
1838
3bd2ef9cbefb
6769873: Regression test java/text/Date/DateFormat/Bug6683975.java started failing after DST ended.
peytoia
parents:
1829
diff
changeset
|
67 |
Date date = new Date(2008-1900, Calendar.SEPTEMBER, 30, 8, 0, 0); |
1829
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
68 |
str_th = df_th.format(date); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
69 |
if (!expected_th[style].equals(str_th)) { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
70 |
err = true; |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
71 |
System.err.println("Error: Formatted date in th locale is incorrect in " + stylePattern[style] + " pattern."); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
72 |
System.err.println("\tExpected: " + expected_th[style]); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
73 |
System.err.println("\tGot: " + str_th); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
74 |
} |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
75 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
76 |
str_th_TH = df_th_TH.format(date); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
77 |
if (!expected_th_TH[style].equals(str_th_TH)) { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
78 |
err = true; |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
79 |
System.err.println("Error: Formatted date in th_TH locale is incorrect in " + stylePattern[style] + " pattern."); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
80 |
System.err.println("\tExpected: " + expected_th_TH[style]); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
81 |
System.err.println("\tGot: " + str_th_TH); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
82 |
} |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
83 |
} |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
84 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
85 |
public static void main(String[] args) { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
86 |
TimeZone timezone = TimeZone.getDefault(); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
87 |
Locale locale = Locale.getDefault(); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
88 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
89 |
TimeZone.setDefault(TimeZone.getTimeZone("US/Pacific")); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
90 |
Locale.setDefault(Locale.US); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
91 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
92 |
try { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
93 |
test(DateFormat.FULL); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
94 |
test(DateFormat.LONG); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
95 |
test(DateFormat.MEDIUM); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
96 |
test(DateFormat.SHORT); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
97 |
} |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
98 |
catch (Exception e) { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
99 |
err = true; |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
100 |
System.err.println("Unexpected exception was thrown: " + e); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
101 |
} |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
102 |
finally { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
103 |
TimeZone.setDefault(timezone); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
104 |
Locale.setDefault(locale); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
105 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
106 |
if (err) { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
107 |
throw new RuntimeException("Failed."); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
108 |
} else { |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
109 |
System.out.println("Passed."); |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
110 |
} |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
111 |
} |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
112 |
} |
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
113 |
|
ee605d03eba7
6683975: [fmt-da] Regression: Java 6 returns English DateFormatPatterns for Thai locale
peytoia
parents:
diff
changeset
|
114 |
} |