1
1
/*
2
- * Copyright (c) 2014, 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
82
82
import org .testng .annotations .Test ;
83
83
84
84
/**
85
- * Test parsing of edge cases.
85
+ * @test
86
+ * @summary Test parsing of edge cases.
87
+ * @bug 8272473
86
88
*/
87
- @ Test
88
89
public class TestDateTimeParsing {
89
90
90
91
private static final ZoneId PARIS = ZoneId .of ("Europe/Paris" );
92
+ private static final ZoneId NEW_YORK = ZoneId .of ("America/New_York" );
91
93
private static final ZoneOffset OFFSET_0230 = ZoneOffset .ofHoursMinutes (2 , 30 );
92
94
93
95
private static final DateTimeFormatter LOCALFIELDS = new DateTimeFormatterBuilder ()
@@ -102,6 +104,7 @@ public class TestDateTimeParsing {
102
104
.appendInstant ().toFormatter ();
103
105
private static final DateTimeFormatter INSTANT_WITH_PARIS = INSTANT .withZone (PARIS );
104
106
private static final DateTimeFormatter INSTANT_WITH_0230 = INSTANT .withZone (OFFSET_0230 );
107
+ private static final DateTimeFormatter INSTANT_WITH_NEW_YORK = INSTANT .withZone (NEW_YORK );
105
108
private static final DateTimeFormatter INSTANT_OFFSETID = new DateTimeFormatterBuilder ()
106
109
.appendInstant ().appendLiteral (' ' ).appendOffsetId ().toFormatter ();
107
110
private static final DateTimeFormatter INSTANT_OFFSETSECONDS = new DateTimeFormatterBuilder ()
@@ -114,6 +117,7 @@ public class TestDateTimeParsing {
114
117
private static final DateTimeFormatter INSTANTSECONDS_NOS_WITH_PARIS = INSTANTSECONDS_NOS .withZone (PARIS );
115
118
private static final DateTimeFormatter INSTANTSECONDS_OFFSETSECONDS = new DateTimeFormatterBuilder ()
116
119
.appendValue (INSTANT_SECONDS ).appendLiteral (' ' ).appendValue (OFFSET_SECONDS ).toFormatter ();
120
+ private static final DateTimeFormatter INSTANTSECONDS_WITH_NEW_YORK = INSTANTSECONDS .withZone (NEW_YORK );
117
121
118
122
@ DataProvider (name = "instantZones" )
119
123
Object [][] data_instantZones () {
@@ -125,11 +129,15 @@ Object[][] data_instantZones() {
125
129
{LOCALFIELDS_WITH_0230 , "2014-06-30 01:02:03" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , OFFSET_0230 )},
126
130
{INSTANT_WITH_PARIS , "2014-06-30T01:02:03Z" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , ZoneOffset .UTC ).withZoneSameInstant (PARIS )},
127
131
{INSTANT_WITH_0230 , "2014-06-30T01:02:03Z" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , ZoneOffset .UTC ).withZoneSameInstant (OFFSET_0230 )},
132
+ {INSTANT_WITH_NEW_YORK , "2020-11-01T05:00:00Z" , ZonedDateTime .of (2020 , 11 , 1 , 5 , 0 , 0 , 0 , ZoneOffset .UTC ).withZoneSameInstant (NEW_YORK )},
133
+ {INSTANT_WITH_NEW_YORK , "2020-11-01T06:00:00Z" , ZonedDateTime .of (2020 , 11 , 1 , 6 , 0 , 0 , 0 , ZoneOffset .UTC ).withZoneSameInstant (NEW_YORK )},
128
134
{INSTANT_OFFSETID , "2014-06-30T01:02:03Z +02:30" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , ZoneOffset .UTC ).withZoneSameInstant (OFFSET_0230 )},
129
135
{INSTANT_OFFSETSECONDS , "2014-06-30T01:02:03Z 9000" , ZonedDateTime .of (2014 , 6 , 30 , 1 , 2 , 3 , 0 , ZoneOffset .UTC ).withZoneSameInstant (OFFSET_0230 )},
130
136
{INSTANTSECONDS_WITH_PARIS , "86402" , Instant .ofEpochSecond (86402 ).atZone (PARIS )},
131
137
{INSTANTSECONDS_NOS_WITH_PARIS , "86402.123456789" , Instant .ofEpochSecond (86402 , 123456789 ).atZone (PARIS )},
132
138
{INSTANTSECONDS_OFFSETSECONDS , "86402 9000" , Instant .ofEpochSecond (86402 ).atZone (OFFSET_0230 )},
139
+ {INSTANTSECONDS_WITH_NEW_YORK , "1604206800" , Instant .ofEpochSecond (1604206800 ).atZone (NEW_YORK )}, // 2020-11-01T05:00:00 UTC
140
+ {INSTANTSECONDS_WITH_NEW_YORK , "1604210400" , Instant .ofEpochSecond (1604210400 ).atZone (NEW_YORK )}, // 2020-11-01T06:00:00 UTC
133
141
};
134
142
}
135
143
0 commit comments