Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/util/Locale/ThaiGov.java
41149 views
1
/*
2
* Copyright (c) 2007, 2020, 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
*/
23
/**
24
* @test
25
* @bug 4474409
26
* @author John O'Conner
27
* @modules jdk.localedata
28
* @run main/othervm -Djava.locale.providers=COMPAT ThaiGov
29
*/
30
31
import java.util.*;
32
import java.text.*;
33
34
public class ThaiGov {
35
36
ThaiGov() {
37
System.out.println("ThaiGov locale test...");
38
39
}
40
41
void numberTest() throws RuntimeException {
42
final String strExpected = "\u0E51\u0E52\u002C\u0E53\u0E54\u0E55\u002C\u0E56\u0E57\u0E58\u002E\u0E52\u0E53\u0E54";
43
final double value = 12345678.234;
44
45
Locale locTH = new Locale("th", "TH", "TH");
46
47
// th_TH_TH test
48
NumberFormat nf = NumberFormat.getInstance(locTH);
49
String str = nf.format(value);
50
51
if (!strExpected.equals(str)) {
52
throw new RuntimeException();
53
}
54
55
}
56
57
void currencyTest() throws RuntimeException {
58
final String strExpected = "\u0E3F\u0E51\u0E52\u002C\u0E53\u0E54\u0E55\u002C\u0E56\u0E57\u0E58\u002E\u0E52\u0E53";
59
final double value = 12345678.234;
60
61
Locale locTH = new Locale("th", "TH", "TH");
62
63
// th_TH_TH test
64
NumberFormat nf = NumberFormat.getCurrencyInstance(locTH);
65
String str = nf.format(value);
66
67
if (!strExpected.equals(str)) {
68
throw new RuntimeException();
69
}
70
71
}
72
73
void dateTest() throws RuntimeException {
74
Locale locTH = new Locale("th", "TH", "TH");
75
TimeZone tz = TimeZone.getTimeZone("PST");
76
77
Calendar calGregorian = Calendar.getInstance(tz, Locale.US);
78
calGregorian.clear();
79
calGregorian.set(2002, 4, 1, 8, 30);
80
final Date date = calGregorian.getTime();
81
Calendar cal = Calendar.getInstance(tz, locTH);
82
cal.clear();
83
cal.setTime(date);
84
85
86
final String strExpected = "\u0E27\u0E31\u0E19\u0E1E\u0E38\u0E18\u0E17\u0E35\u0E48\u0020\u0E51\u0020\u0E1E\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21\u0020\u0E1E\u002E\u0E28\u002E\u0020\u0E52\u0E55\u0E54\u0E55\u002C\u0020\u0E58\u0020\u0E19\u0E32\u0E2C\u0E34\u0E01\u0E32\u0020\u0E53\u0E50\u0020\u0E19\u0E32\u0E17\u0E35\u0020\u0E50\u0E50\u0020\u0E27\u0E34\u0E19\u0E32\u0E17\u0E35";
87
Date value = cal.getTime();
88
89
// th_TH_TH test
90
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locTH);
91
df.setTimeZone(tz);
92
String str = df.format(value);
93
94
if (!strExpected.equals(str)) {
95
throw new RuntimeException();
96
}
97
98
}
99
100
public static void main(String[] args) {
101
102
ThaiGov app = new ThaiGov();
103
System.out.print("Running numberTest...");
104
app.numberTest();
105
System.out.print("Finished\n");
106
System.out.print("Running currencyTest...");
107
app.currencyTest();
108
System.out.print("Finished\n");
109
System.out.print("Running dateTest...");
110
app.dateTest();
111
System.out.print("Finished\n");
112
113
System.out.println("PASSED");
114
}
115
116
117
}
118
119