Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/util/resources/cldr/Bug8134384.java
41153 views
1
/*
2
* Copyright (c) 2015, 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
/*
25
* @test
26
* @bug 8134384 8234347 8236548
27
* @summary Tests CLDR TimeZoneNames has English names for all tzids
28
* @run main/othervm -Djava.locale.providers=CLDR Bug8134384
29
*/
30
31
import java.text.*;
32
import java.time.*;
33
import java.util.*;
34
35
public class Bug8134384 {
36
public static void main(String [] args) {
37
TimeZone original = TimeZone.getDefault();
38
39
try {
40
for (String tz : TimeZone.getAvailableIDs() ) {
41
TimeZone.setDefault(TimeZone.getTimeZone(tz));
42
// Summer solstice
43
String date1 = Date.from(Instant.parse("2015-06-21T00:00:00.00Z")).toString();
44
testParse(Locale.ENGLISH, date1, tz);
45
testParse(Locale.US, date1, tz);
46
// Winter solstice
47
String date2 = Date.from(Instant.parse("2015-12-22T00:00:00.00Z")).toString();
48
testParse(Locale.ENGLISH, date2, tz);
49
testParse(Locale.US, date2, tz);
50
}
51
} finally {
52
TimeZone.setDefault(original);
53
}
54
}
55
56
private static void testParse(Locale locale, String date, String tz) {
57
try {
58
new SimpleDateFormat("EEE MMM d hh:mm:ss z yyyy", locale).parse(date);
59
System.out.println(String.format(Locale.ENGLISH, "OK parsing '%s' in locale '%s', tz: %s", date, locale, tz));
60
} catch (ParseException pe) {
61
throw new RuntimeException(String.format(Locale.ENGLISH, "ERROR parsing '%s' in locale '%s', tz: %s: %s", date, locale, tz, pe.toString()));
62
}
63
}
64
}
65
66