1
1
/*
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.
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
88
88
/**
89
89
* @test
90
90
* @summary Test parsing of edge cases.
91
- * @bug 8223773
91
+ * @bug 8223773 8272473
92
92
*/
93
93
public class TestDateTimeParsing {
94
94
95
95
private static final ZoneId PARIS = ZoneId .of ("Europe/Paris" );
96
+ private static final ZoneId NEW_YORK = ZoneId .of ("America/New_York" );
96
97
private static final ZoneOffset OFFSET_0230 = ZoneOffset .ofHoursMinutes (2 , 30 );
97
98
98
99
private static final DateTimeFormatter LOCALFIELDS = new DateTimeFormatterBuilder ()
@@ -107,6 +108,7 @@ public class TestDateTimeParsing {
107
108
.appendInstant ().toFormatter ();
108
109
private static final DateTimeFormatter INSTANT_WITH_PARIS = INSTANT .withZone (PARIS );
109
110
private static final DateTimeFormatter INSTANT_WITH_0230 = INSTANT .withZone (OFFSET_0230 );
111
+ private static final DateTimeFormatter INSTANT_WITH_NEW_YORK = INSTANT .withZone (NEW_YORK );
110
112
private static final DateTimeFormatter INSTANT_OFFSETID = new DateTimeFormatterBuilder ()
111
113
.appendInstant ().appendLiteral (' ' ).appendOffsetId ().toFormatter ();
112
114
private static final DateTimeFormatter INSTANT_OFFSETSECONDS = new DateTimeFormatterBuilder ()
@@ -119,6 +121,7 @@ public class TestDateTimeParsing {
119
121
private static final DateTimeFormatter INSTANTSECONDS_NOS_WITH_PARIS = INSTANTSECONDS_NOS .withZone (PARIS );
120
122
private static final DateTimeFormatter INSTANTSECONDS_OFFSETSECONDS = new DateTimeFormatterBuilder ()
121
123
.appendValue (INSTANT_SECONDS ).appendLiteral (' ' ).appendValue (OFFSET_SECONDS ).toFormatter ();
124
+ private static final DateTimeFormatter INSTANTSECONDS_WITH_NEW_YORK = INSTANTSECONDS .withZone (NEW_YORK );
122
125
123
126
private static final String DTPE_MESSAGE =
124
127
"Invalid value for HourOfAmPm (valid values 0 - 11): 12" ;
@@ -133,11 +136,15 @@ Object[][] data_instantZones() {
133
136
{LOCALFIELDS_WITH_0230 , "2014-06-30 01:02:03" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , OFFSET_0230 )},
134
137
{INSTANT_WITH_PARIS , "2014-06-30T01:02:03Z" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , ZoneOffset .UTC ).withZoneSameInstant (PARIS )},
135
138
{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 )},
136
141
{INSTANT_OFFSETID , "2014-06-30T01:02:03Z +02:30" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , ZoneOffset .UTC ).withZoneSameInstant (OFFSET_0230 )},
137
142
{INSTANT_OFFSETSECONDS , "2014-06-30T01:02:03Z 9000" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , ZoneOffset .UTC ).withZoneSameInstant (OFFSET_0230 )},
138
143
{INSTANTSECONDS_WITH_PARIS , "86402" , Instant .ofEpochSecond (86402 ).atZone (PARIS )},
139
144
{INSTANTSECONDS_NOS_WITH_PARIS , "86402.123456789" , Instant .ofEpochSecond (86402 , 123456789 ).atZone (PARIS )},
140
145
{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
141
148
};
142
149
}
143
150
0 commit comments