Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/util/resources/cldr/Bug8134250.java
41153 views
1
/*
2
* Copyright (c) 2015, 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
*/
23
24
/*
25
* @test
26
* @bug 8134250 8134520
27
* @modules jdk.localedata
28
* @summary Tests CLDR/LDML features are correctly reflected in JDK.
29
* @run main/othervm -Djava.locale.providers=CLDR Bug8134250
30
*/
31
32
// Note this test highly depends on a particular version of CLDR. Results
33
// may vary in the future.
34
35
import java.time.LocalDate;
36
import java.time.Month;
37
import java.time.ZoneId;
38
import java.time.chrono.Chronology;
39
import java.time.format.DateTimeFormatter;
40
import java.time.format.DateTimeFormatterBuilder;
41
import java.time.format.FormatStyle;
42
import java.time.format.TextStyle;
43
import java.util.Locale;
44
45
public class Bug8134250 {
46
public static void main(String [] args) {
47
LocalDate d = LocalDate.of(1980, Month.JANUARY, 1);
48
49
// en-GB inherits from en-001 where its short tz name for
50
// America/Los_Angeles is "non-inheritance marker". Thus the
51
// resulting formatted text should be a custom ID.
52
DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder();
53
dtfb.appendZoneText(TextStyle.SHORT);
54
DateTimeFormatter dtf = dtfb.toFormatter(Locale.UK)
55
.withZone(ZoneId.of("America/Los_Angeles"));
56
String result = dtf.format(d);
57
System.out.println(result);
58
if (!"GMT-08:00".equals(result)) {
59
throw new RuntimeException("short time zone name for America/Los_Angeles in en_GB is incorrect. Got: " + result + ", expected: GMT-08:00");
60
}
61
62
// Islamic Um-Alqura calendar is an alias to Islamic calendar.
63
// In Islamic calendar data, only month names are localized, also
64
// date/time format for FULL style should be inherited from "generic"
65
// calendar, where it includes ERA field.
66
Locale locale = Locale.forLanguageTag("en-US-u-ca-islamic-umalqura");
67
Chronology chrono = Chronology.ofLocale(locale);
68
dtf = DateTimeFormatter
69
.ofLocalizedDate(FormatStyle.FULL)
70
.withLocale(locale)
71
.withChronology(chrono);
72
result = dtf.format(d);
73
System.out.println(dtf.format(d));
74
if (!"Tuesday, Safar 12, 1400 AH".equals(result)) {
75
throw new RuntimeException("FULL date format of Islamic Um-Alqura calendar in en_US is incorrect. Got: " + result + ", expected: Tuesday, Safar 12, 1400 AH");
76
}
77
}
78
}
79
80