@@ -280,7 +280,10 @@ public void shouldWriteZonedDateTimeWithOffset() throws Exception
280
280
int index = buf .readableBytes () - Integer .BYTES - Byte .BYTES - Short .BYTES - Byte .BYTES - Integer .BYTES - Byte .BYTES ;
281
281
ByteBuf tailSlice = buf .slice ( index , buf .readableBytes () - index );
282
282
283
- assertByteBufContains ( tailSlice , INT_32 , (int ) dateTime .toEpochSecond (), INT_16 , (short ) dateTime .getNano (), INT_32 , zoneOffset .getTotalSeconds () );
283
+ assertByteBufContains ( tailSlice ,
284
+ INT_32 , (int ) localEpochSecondOf ( dateTime ),
285
+ INT_16 , (short ) dateTime .getNano (),
286
+ INT_32 , zoneOffset .getTotalSeconds () );
284
287
}
285
288
286
289
@ Test
@@ -292,7 +295,7 @@ public void shouldReadZonedDateTimeWithOffset() throws Exception
292
295
Object unpacked = packAndUnpackValue ( packer ->
293
296
{
294
297
packer .packStructHeader ( 3 , (byte ) 'F' );
295
- packer .pack ( dateTime . toInstant (). getEpochSecond ( ) );
298
+ packer .pack ( localEpochSecondOf ( dateTime ) );
296
299
packer .pack ( dateTime .toInstant ().getNano () );
297
300
packer .pack ( zoneOffset .getTotalSeconds () );
298
301
} );
@@ -316,7 +319,7 @@ public void shouldWriteZonedDateTimeWithZoneId() throws Exception
316
319
ByteBuf tailSlice = buf .slice ( index , buf .readableBytes () - index );
317
320
318
321
List <Number > expectedBuf = new ArrayList <>( asList (
319
- INT_32 , (int ) dateTime . toInstant (). getEpochSecond ( ),
322
+ INT_32 , (int ) localEpochSecondOf ( dateTime ),
320
323
INT_16 , (short ) dateTime .toInstant ().getNano (),
321
324
STRING_8 , (byte ) zoneNameBytes .length ) );
322
325
@@ -337,7 +340,7 @@ public void shouldReadZonedDateTimeWithZoneId() throws Exception
337
340
Object unpacked = packAndUnpackValue ( packer ->
338
341
{
339
342
packer .packStructHeader ( 3 , (byte ) 'f' );
340
- packer .pack ( dateTime . toInstant (). getEpochSecond ( ) );
343
+ packer .pack ( localEpochSecondOf ( dateTime ) );
341
344
packer .pack ( dateTime .toInstant ().getNano () );
342
345
packer .pack ( zoneName );
343
346
} );
@@ -425,4 +428,9 @@ private MessageFormat.Writer newWriter( ByteBuf buf )
425
428
{
426
429
return messageFormat .newWriter ( new ByteBufOutput ( buf ), true );
427
430
}
431
+
432
+ private static long localEpochSecondOf ( ZonedDateTime dateTime )
433
+ {
434
+ return dateTime .toLocalDateTime ().toEpochSecond ( UTC );
435
+ }
428
436
}
0 commit comments