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 4747import sun .util .calendar .ZoneInfo ;
4848import sun .util .calendar .ZoneInfoFile ;
4949import sun .util .locale .provider .TimeZoneNameUtility ;
50- import sun .util .logging .PlatformLogger ;
5150
5251/**
5352 * {@code TimeZone} represents a time zone offset, and also figures out daylight
@@ -599,9 +598,9 @@ private ZoneId toZoneId0() {
599598
600599 private static TimeZone getTimeZone (String ID , boolean fallback ) {
601600 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 );
605604 }
606605 TimeZone tz = ZoneInfo .getTimeZone (ID );
607606 if (tz == null ) {
Original file line number Diff line number Diff line change 2323
2424/*
2525 * @test
26- * @bug 8342550
26+ * @bug 8342550 8349873
2727 * @summary Three-letter time zone IDs should output a deprecated warning
2828 * message.
2929 * @library /test/lib
3030 * @build jdk.test.lib.process.ProcessTools
31- * @run main ThreeLetterZoneID
31+ * @run junit ThreeLetterZoneID
3232 */
3333import java .util .TimeZone ;
3434import jdk .test .lib .process .ProcessTools ;
3535
36+ import org .junit .jupiter .api .Test ;
37+
3638public 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 ) {
3843 if (args .length > 0 ) {
3944 TimeZone .getTimeZone ("PST" );
4045 } else {
41- checkWarningMessage ();
46+ TimeZone . getDefault ();
4247 }
4348 }
4449
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 );
4858 }
4959}
You can’t perform that action at this time.
0 commit comments