11/*
2- * Copyright (c) 2014, 2019 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2014, 2021 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
8888/**
8989 * @test
9090 * @summary Test parsing of edge cases.
91- * @bug 8223773
91+ * @bug 8223773 8272473
9292 */
9393public class TestDateTimeParsing {
9494
9595 private static final ZoneId PARIS = ZoneId .of ("Europe/Paris" );
96+ private static final ZoneId NEW_YORK = ZoneId .of ("America/New_York" );
9697 private static final ZoneOffset OFFSET_0230 = ZoneOffset .ofHoursMinutes (2 , 30 );
9798
9899 private static final DateTimeFormatter LOCALFIELDS = new DateTimeFormatterBuilder ()
@@ -107,6 +108,7 @@ public class TestDateTimeParsing {
107108 .appendInstant ().toFormatter ();
108109 private static final DateTimeFormatter INSTANT_WITH_PARIS = INSTANT .withZone (PARIS );
109110 private static final DateTimeFormatter INSTANT_WITH_0230 = INSTANT .withZone (OFFSET_0230 );
111+ private static final DateTimeFormatter INSTANT_WITH_NEW_YORK = INSTANT .withZone (NEW_YORK );
110112 private static final DateTimeFormatter INSTANT_OFFSETID = new DateTimeFormatterBuilder ()
111113 .appendInstant ().appendLiteral (' ' ).appendOffsetId ().toFormatter ();
112114 private static final DateTimeFormatter INSTANT_OFFSETSECONDS = new DateTimeFormatterBuilder ()
@@ -119,6 +121,7 @@ public class TestDateTimeParsing {
119121 private static final DateTimeFormatter INSTANTSECONDS_NOS_WITH_PARIS = INSTANTSECONDS_NOS .withZone (PARIS );
120122 private static final DateTimeFormatter INSTANTSECONDS_OFFSETSECONDS = new DateTimeFormatterBuilder ()
121123 .appendValue (INSTANT_SECONDS ).appendLiteral (' ' ).appendValue (OFFSET_SECONDS ).toFormatter ();
124+ private static final DateTimeFormatter INSTANTSECONDS_WITH_NEW_YORK = INSTANTSECONDS .withZone (NEW_YORK );
122125
123126 private static final String DTPE_MESSAGE =
124127 "Invalid value for HourOfAmPm (valid values 0 - 11): 12" ;
@@ -133,11 +136,15 @@ Object[][] data_instantZones() {
133136 {LOCALFIELDS_WITH_0230 , "2014-06-30 01:02:03" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , OFFSET_0230 )},
134137 {INSTANT_WITH_PARIS , "2014-06-30T01:02:03Z" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , ZoneOffset .UTC ).withZoneSameInstant (PARIS )},
135138 {INSTANT_WITH_0230 , "2014-06-30T01:02:03Z" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , ZoneOffset .UTC ).withZoneSameInstant (OFFSET_0230 )},
139+ {INSTANT_WITH_NEW_YORK , "2020-11-01T05:00:00Z" , ZonedDateTime .of (2020 , 11 , 1 , 5 , 0 , 0 , 0 , ZoneOffset .UTC ).withZoneSameInstant (NEW_YORK )},
140+ {INSTANT_WITH_NEW_YORK , "2020-11-01T06:00:00Z" , ZonedDateTime .of (2020 , 11 , 1 , 6 , 0 , 0 , 0 , ZoneOffset .UTC ).withZoneSameInstant (NEW_YORK )},
136141 {INSTANT_OFFSETID , "2014-06-30T01:02:03Z +02:30" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , ZoneOffset .UTC ).withZoneSameInstant (OFFSET_0230 )},
137142 {INSTANT_OFFSETSECONDS , "2014-06-30T01:02:03Z 9000" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , ZoneOffset .UTC ).withZoneSameInstant (OFFSET_0230 )},
138143 {INSTANTSECONDS_WITH_PARIS , "86402" , Instant .ofEpochSecond (86402 ).atZone (PARIS )},
139144 {INSTANTSECONDS_NOS_WITH_PARIS , "86402.123456789" , Instant .ofEpochSecond (86402 , 123456789 ).atZone (PARIS )},
140145 {INSTANTSECONDS_OFFSETSECONDS , "86402 9000" , Instant .ofEpochSecond (86402 ).atZone (OFFSET_0230 )},
146+ {INSTANTSECONDS_WITH_NEW_YORK , "1604206800" , Instant .ofEpochSecond (1604206800 ).atZone (NEW_YORK )}, // 2020-11-01T05:00:00 UTC
147+ {INSTANTSECONDS_WITH_NEW_YORK , "1604210400" , Instant .ofEpochSecond (1604210400 ).atZone (NEW_YORK )}, // 2020-11-01T06:00:00 UTC
141148 };
142149 }
143150
0 commit comments