1 /*
2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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.
22 */
48 "30 \u0e01.\u0e22. 2551, 8:00:00", // 2: MEDIUM
49 "30/9/2551, 8:00 \u0e19." // 3: SHORT
50 };
51 private static String stylePattern[] = {
52 "FULL", "LONG", "MEDIUM", "SHORT"
53 };
54
55 private static void test(int style) {
56 DateFormat df_th = DateFormat.getDateTimeInstance(style, style, th);
57 DateFormat df_th_TH = DateFormat.getDateTimeInstance(style, style, th_TH);
58
59 String str_th = ((SimpleDateFormat)df_th).toPattern();
60 String str_th_TH = ((SimpleDateFormat)df_th_TH).toPattern();
61 if (!str_th.equals(str_th_TH)) {
62 err = true;
63 System.err.println("Error: Pattern for th locale should be the same as pattern for th_TH locale. (" + stylePattern[style] + ")");
64 System.err.println("\tth: " + str_th);
65 System.err.println("\tth_TH: " + str_th_TH);
66 }
67
68 Date date = new Date(2008-1900, Calendar.SEPTEMBER, 30, 8, 0, 0);
69 str_th = df_th.format(date);
70 if (!expected_th[style].equals(str_th)) {
71 err = true;
72 System.err.println("Error: Formatted date in th locale is incorrect in " + stylePattern[style] + " pattern.");
73 System.err.println("\tExpected: " + expected_th[style]);
74 System.err.println("\tGot: " + str_th);
75 }
76
77 str_th_TH = df_th_TH.format(date);
78 if (!expected_th_TH[style].equals(str_th_TH)) {
79 err = true;
80 System.err.println("Error: Formatted date in th_TH locale is incorrect in " + stylePattern[style] + " pattern.");
81 System.err.println("\tExpected: " + expected_th_TH[style]);
82 System.err.println("\tGot: " + str_th_TH);
83 }
84 }
85
86 public static void main(String[] args) {
87 TimeZone timezone = TimeZone.getDefault();
|
1 /*
2 * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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.
22 */
48 "30 \u0e01.\u0e22. 2551, 8:00:00", // 2: MEDIUM
49 "30/9/2551, 8:00 \u0e19." // 3: SHORT
50 };
51 private static String stylePattern[] = {
52 "FULL", "LONG", "MEDIUM", "SHORT"
53 };
54
55 private static void test(int style) {
56 DateFormat df_th = DateFormat.getDateTimeInstance(style, style, th);
57 DateFormat df_th_TH = DateFormat.getDateTimeInstance(style, style, th_TH);
58
59 String str_th = ((SimpleDateFormat)df_th).toPattern();
60 String str_th_TH = ((SimpleDateFormat)df_th_TH).toPattern();
61 if (!str_th.equals(str_th_TH)) {
62 err = true;
63 System.err.println("Error: Pattern for th locale should be the same as pattern for th_TH locale. (" + stylePattern[style] + ")");
64 System.err.println("\tth: " + str_th);
65 System.err.println("\tth_TH: " + str_th_TH);
66 }
67
68 @SuppressWarnings("deprecation")
69 Date date = new Date(2008-1900, Calendar.SEPTEMBER, 30, 8, 0, 0);
70 str_th = df_th.format(date);
71 if (!expected_th[style].equals(str_th)) {
72 err = true;
73 System.err.println("Error: Formatted date in th locale is incorrect in " + stylePattern[style] + " pattern.");
74 System.err.println("\tExpected: " + expected_th[style]);
75 System.err.println("\tGot: " + str_th);
76 }
77
78 str_th_TH = df_th_TH.format(date);
79 if (!expected_th_TH[style].equals(str_th_TH)) {
80 err = true;
81 System.err.println("Error: Formatted date in th_TH locale is incorrect in " + stylePattern[style] + " pattern.");
82 System.err.println("\tExpected: " + expected_th_TH[style]);
83 System.err.println("\tGot: " + str_th_TH);
84 }
85 }
86
87 public static void main(String[] args) {
88 TimeZone timezone = TimeZone.getDefault();
|