1
1
/*
2
- * Copyright (c) 2012, 2018 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2012, 2022 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
49
49
50
50
/*
51
51
* @test
52
- * @bug 8081022 8151876 8166875 8189784 8206980
52
+ * @bug 8081022 8151876 8166875 8189784 8206980 8278434
53
53
* @key randomness
54
54
*/
55
55
59
59
@ Test
60
60
public class TestZoneTextPrinterParser extends AbstractTestPrinterParser {
61
61
62
+ private static final Locale [] SAMPLE_LOCALES = {
63
+ Locale .US , Locale .UK , Locale .FRANCE , Locale .GERMANY , Locale .ITALY , Locale .forLanguageTag ("es" ),
64
+ Locale .forLanguageTag ("pt-BR" ), Locale .forLanguageTag ("ru" ),
65
+ Locale .CHINA , Locale .TAIWAN , Locale .JAPAN , Locale .KOREA , Locale .ROOT };
66
+
62
67
protected static DateTimeFormatter getFormatter (Locale locale , TextStyle style ) {
63
68
return new DateTimeFormatterBuilder ().appendZoneText (style )
64
69
.toFormatter (locale )
@@ -68,7 +73,6 @@ protected static DateTimeFormatter getFormatter(Locale locale, TextStyle style)
68
73
public void test_printText () {
69
74
Random r = RandomFactory .getRandom ();
70
75
int N = 8 ;
71
- Locale [] locales = Locale .getAvailableLocales ();
72
76
Set <String > zids = ZoneRulesProvider .getAvailableZoneIds ();
73
77
ZonedDateTime zdt = ZonedDateTime .now ();
74
78
@@ -83,7 +87,7 @@ public void test_printText() {
83
87
zdt = zdt .withZoneSameLocal (ZoneId .of (zid ));
84
88
TimeZone tz = TimeZone .getTimeZone (zid );
85
89
boolean isDST = tz .inDaylightTime (new Date (zdt .toInstant ().toEpochMilli ()));
86
- for (Locale locale : locales ) {
90
+ for (Locale locale : SAMPLE_LOCALES ) {
87
91
String longDisplayName = tz .getDisplayName (isDST , TimeZone .LONG , locale );
88
92
String shortDisplayName = tz .getDisplayName (isDST , TimeZone .SHORT , locale );
89
93
if ((longDisplayName .startsWith ("GMT+" ) && shortDisplayName .startsWith ("GMT+" ))
@@ -116,9 +120,8 @@ private void printText(Locale locale, ZonedDateTime zdt, TextStyle style, TimeZo
116
120
}
117
121
118
122
public void test_ParseText () {
119
- Locale [] locales = new Locale [] { Locale .ENGLISH , Locale .JAPANESE , Locale .FRENCH };
120
123
Set <String > zids = ZoneRulesProvider .getAvailableZoneIds ();
121
- for (Locale locale : locales ) {
124
+ for (Locale locale : SAMPLE_LOCALES ) {
122
125
parseText (zids , locale , TextStyle .FULL , false );
123
126
parseText (zids , locale , TextStyle .FULL , true );
124
127
parseText (zids , locale , TextStyle .SHORT , false );
0 commit comments