File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed
src/java.base/share/classes/java/util
test/jdk/java/util/TimeZone Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change 47
47
import sun .util .calendar .ZoneInfo ;
48
48
import sun .util .calendar .ZoneInfoFile ;
49
49
import sun .util .locale .provider .TimeZoneNameUtility ;
50
- import sun .util .logging .PlatformLogger ;
51
50
52
51
/**
53
52
* {@code TimeZone} represents a time zone offset, and also figures out daylight
@@ -599,9 +598,9 @@ private ZoneId toZoneId0() {
599
598
600
599
private static TimeZone getTimeZone (String ID , boolean fallback ) {
601
600
if (ZoneId .SHORT_IDS .containsKey (ID )) {
602
- PlatformLogger . getLogger ( TimeZone . class . getName ())
603
- . warning ( " Use of the three-letter time zone ID \" %s\" is deprecated and it will be removed in a future release"
604
- . formatted ( ID ) );
601
+ System . err . printf (
602
+ "WARNING: Use of the three-letter time zone ID \" %s\" is deprecated and it will be removed in a future release%n" ,
603
+ ID );
605
604
}
606
605
TimeZone tz = ZoneInfo .getTimeZone (ID );
607
606
if (tz == null ) {
Original file line number Diff line number Diff line change 23
23
24
24
/*
25
25
* @test
26
- * @bug 8342550
26
+ * @bug 8342550 8349873
27
27
* @summary Three-letter time zone IDs should output a deprecated warning
28
28
* message.
29
29
* @library /test/lib
30
30
* @build jdk.test.lib.process.ProcessTools
31
- * @run main ThreeLetterZoneID
31
+ * @run junit ThreeLetterZoneID
32
32
*/
33
33
import java .util .TimeZone ;
34
34
import jdk .test .lib .process .ProcessTools ;
35
35
36
+ import org .junit .jupiter .api .Test ;
37
+
36
38
public class ThreeLetterZoneID {
37
- public static void main (String ... args ) throws Exception {
39
+ private static final String WARNING =
40
+ "WARNING: Use of the three-letter time zone ID \" PST\" is deprecated and it will be removed in a future release" ;
41
+
42
+ public static void main (String ... args ) {
38
43
if (args .length > 0 ) {
39
44
TimeZone .getTimeZone ("PST" );
40
45
} else {
41
- checkWarningMessage ();
46
+ TimeZone . getDefault ();
42
47
}
43
48
}
44
49
45
- public static void checkWarningMessage () throws Exception {
46
- ProcessTools .executeTestJava ("ThreeLetterZoneID" , "dummy" )
47
- .shouldContain ("Use of the three-letter time zone ID \" PST\" is deprecated and it will be removed in a future release" );
50
+ @ Test
51
+ public void testExplicitGetTimeZone () throws Exception {
52
+ ProcessTools .executeTestJava ("ThreeLetterZoneID" , "dummy" ).stderrShouldMatch (WARNING );
53
+ }
54
+
55
+ @ Test
56
+ public void testSysProp () throws Exception {
57
+ ProcessTools .executeTestJava ("-Duser.timezone=PST" , "ThreeLetterZoneID" ).stderrShouldMatch (WARNING );
48
58
}
49
59
}
You can’t perform that action at this time.
0 commit comments