4040import java .util .List ;
4141import java .util .Map ;
4242import java .util .UUID ;
43+ import java .util .concurrent .TimeUnit ;
4344import java .util .stream .Collectors ;
4445import org .apache .avro .Conversions ;
4546import org .apache .avro .LogicalTypes ;
@@ -400,13 +401,14 @@ enum TestEnum {
400401 .set ("uuidValue" , uuid .toString ())
401402 .build ();
402403
404+ org .joda .time .LocalTime localTime = org .joda .time .LocalTime .fromMillisOfDay (42_000L );
403405 jodaTimeLogicalTypesRecord =
404406 new GenericRecordBuilder (LOGICAL_TYPES_SCHEMA )
405407 .set ("numericValue" , numeric )
406408 .set ("bigNumericValue" , bigNumeric )
407409 .set ("dateValue" , new org .joda .time .LocalDate (1970 , 1 , 1 ).plusDays (42 ))
408- .set ("timeMicrosValue" , org . joda . time . LocalTime . fromMillisOfDay ( 42_000L ) )
409- .set ("timeMillisValue" , org . joda . time . LocalTime . fromMillisOfDay ( 42_000L ) )
410+ .set ("timeMicrosValue" , localTime )
411+ .set ("timeMillisValue" , localTime )
410412 .set ("timestampMicrosValue" , org .joda .time .Instant .ofEpochSecond (42L ))
411413 .set ("timestampMillisValue" , org .joda .time .Instant .ofEpochSecond (42L ))
412414 .set (
@@ -423,8 +425,14 @@ enum TestEnum {
423425 .set ("numericValue" , numeric )
424426 .set ("bigNumericValue" , bigNumeric )
425427 .set ("dateValue" , java .time .LocalDate .ofEpochDay (42L ))
426- .set ("timeMicrosValue" , java .time .LocalTime .ofSecondOfDay (42L ))
427- .set ("timeMillisValue" , java .time .LocalTime .ofSecondOfDay (42L ))
428+ .set (
429+ "timeMicrosValue" ,
430+ java .time .LocalTime .ofNanoOfDay (
431+ TimeUnit .MILLISECONDS .toNanos (localTime .getMillisOfDay ())))
432+ .set (
433+ "timeMillisValue" ,
434+ java .time .LocalTime .ofNanoOfDay (
435+ TimeUnit .MILLISECONDS .toNanos (localTime .getMillisOfDay ())))
428436 .set ("timestampMicrosValue" , java .time .Instant .ofEpochSecond (42L ))
429437 .set ("timestampMillisValue" , java .time .Instant .ofEpochSecond (42L ))
430438 .set (
@@ -456,8 +464,8 @@ enum TestEnum {
456464 .put ("numericvalue" , numericBytes )
457465 .put ("bignumericvalue" , bigNumericBytes )
458466 .put ("datevalue" , 42 )
459- .put ("timemicrosvalue" , 42_000_000L )
460- .put ("timemillisvalue" , 42_000_000L )
467+ .put ("timemicrosvalue" , CivilTimeEncoder . encodePacked64TimeMicros ( localTime ) )
468+ .put ("timemillisvalue" , CivilTimeEncoder . encodePacked64TimeMicros ( localTime ) )
461469 .put ("timestampmicrosvalue" , 42_000_000L )
462470 .put ("timestampmillisvalue" , 42_000_000L )
463471 .put ("localtimestampmicrosvalue" , 42_000_000L )
0 commit comments