@@ -134,6 +134,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest {
134
134
private static final ZoneId ZONE_GAZA = ZoneId .of ("Asia/Gaza" );
135
135
private static final ZoneOffset OFFSET_PONE = ZoneOffset .ofHours (1 );
136
136
private static final ZoneOffset OFFSET_PTWO = ZoneOffset .ofHours (2 );
137
+ private static final ZoneOffset OFFSET_MTWO = ZoneOffset .ofHours (-2 );
137
138
private static final LocalDate DATE = LocalDate .of (2008 , 12 , 3 );
138
139
private OffsetTime TEST_11_30_59_500_PONE ;
139
140
@@ -1148,6 +1149,29 @@ public void test_format_formatter_null() {
1148
1149
OffsetTime .of (11 , 30 , 0 , 0 , OFFSET_PONE ).format (null );
1149
1150
}
1150
1151
1152
+ //-----------------------------------------------------------------------
1153
+ // toEpochSecond()
1154
+ //-----------------------------------------------------------------------
1155
+ @ DataProvider (name ="epochSecond" )
1156
+ Object [][] provider_toEpochSecond () {
1157
+ return new Object [][] {
1158
+ {OffsetTime .of (0 , 0 , 0 , 0 , OFFSET_PTWO ).toEpochSecond (LocalDate .of (1970 , 1 , 1 )), -7200L },
1159
+ {OffsetTime .of (11 , 30 , 0 , 0 , OFFSET_MTWO ).toEpochSecond (LocalDate .of (1995 , 9 , 27 )), 812208600L },
1160
+ {OffsetTime .of (0 , 0 , 0 , 0 , OFFSET_PONE ).toEpochSecond (LocalDate .of (1970 , 1 , 1 )),
1161
+ Instant .ofEpochSecond (-3600 ).getEpochSecond ()},
1162
+ {OffsetTime .of (11 , 30 , 0 , 0 , OFFSET_PTWO ).toEpochSecond (LocalDate .of (1965 , 12 , 31 )),
1163
+ Instant .ofEpochSecond (-126282600L ).getEpochSecond ()},
1164
+ {OffsetTime .of (11 , 30 , 0 , 0 , OFFSET_MTWO ).toEpochSecond (LocalDate .of (1970 , 1 , 1 )),
1165
+ OffsetDateTime .of (LocalDate .of (1970 , 1 , 1 ), LocalTime .of (11 , 30 ), OFFSET_MTWO )
1166
+ .toEpochSecond ()},
1167
+ };
1168
+ }
1169
+
1170
+ @ Test (dataProvider ="epochSecond" )
1171
+ public void test_toEpochSecond (long actual , long expected ) {
1172
+ assertEquals (actual , expected );
1173
+ }
1174
+
1151
1175
//-----------------------------------------------------------------------
1152
1176
// compareTo()
1153
1177
//-----------------------------------------------------------------------
0 commit comments