protected Object convertToAsyncDriverTypes ( Object object ) { if ( object instanceof Enum ) { return ( ( Enum ) object ) . name ( ) ; } else if ( object instanceof LocalDateTime ) { LocalDateTime convert = ( LocalDateTime ) object ; return new org . joda . time . LocalDateTime ( convert . getYear ( ) , convert . getMonthValue ( ) , convert . getDayOfMonth ( ) , convert . getHour ( ) , convert . getMinute ( ) , convert . getSecond ( ) , convert . get ( ChronoField . MILLI_OF_SECOND ) ) ; } else if ( object instanceof LocalDate ) { LocalDate convert = ( LocalDate ) object ; return new org . joda . time . LocalDate ( convert . getYear ( ) , convert . getMonthValue ( ) , convert . getDayOfMonth ( ) ) ; } else if ( object instanceof ZonedDateTime ) { ZonedDateTime convert = ( ZonedDateTime ) object ; return new org . joda . time . DateTime ( convert . getYear ( ) , convert . getMonthValue ( ) , convert . getDayOfMonth ( ) , convert . getHour ( ) , convert . getMinute ( ) , convert . getSecond ( ) , convert . get ( ChronoField . MILLI_OF_SECOND ) , DateTimeZone . forID ( convert . getZone ( ) . getId ( ) ) ) ; } else if ( object instanceof OffsetDateTime ) { OffsetDateTime obj = ( OffsetDateTime ) object ; // Keep the same instant when converting to date time ZonedDateTime convert = obj . toZonedDateTime ( ) ; org . joda . time . DateTime dt = new org . joda . time . DateTime ( convert . getYear ( ) , convert . getMonthValue ( ) , convert . getDayOfMonth ( ) , convert . getHour ( ) , convert . getMinute ( ) , convert . getSecond ( ) , convert . get ( ChronoField . MILLI_OF_SECOND ) , DateTimeZone . forID ( convert . getZone ( ) . getId ( ) ) ) ; return dt ; } else if ( object instanceof Instant ) { Instant convert = ( Instant ) object ; org . joda . time . Instant i = org . joda . time . Instant . parse ( convert . toString ( ) ) ; return i . toDateTime ( ) ; } return object ; }
Async - driver uses joda - time instead of java - time so we need to convert it .