You have to provide your own converter for the conversion you want to have between Timestamp
and LocalDate
.
Check a similar example from jooq
.
In your case it would be
import java.sql.Timestamp;
import java.time.LocalDate;
import org.jooq.Converter;
public class LocalDateConverter implements Converter<Timestamp, LocalDate> {
@Override
public LocalDate from(Timestamp t) {
return t == null ? null : t.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
@Override
public Timestamp to(LocalDate u) {
return u == null ? null : Timestamp.valueOf(u.atTime(LocalTime.MIDNIGHT));
}
@Override
public Class<Timestamp> fromType() {
return Timestamp.class;
}
@Override
public Class<LocalDate> toType() {
return LocalDate.class;
}
}
In the above example I have used ZoneId.systemDefault()
for the conversion of timestamp
to localdate
and also LocalTime.MIDNIGHT
for conversion of localdate
to timestamp
. This might be a bit dangerous and should be investigated from you if another specific zoneId should be used for your systems to work as expected.
Then you can use it as
.where(MY_TABLE.UPDATED_AT.asConvertedDataType(new LocalDateConverter()).eq(cashDate))