jooq比较了两个日期,它不喜欢java。sql。日期
我收到以下代码错误:
Date todayDate = new Date();
SimpleDateFormat dataDateFmt = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat dataTimeFmt = new SimpleDateFormat("HHmmss");
java.sql.Date nowDate = java.sql.Date.valueOf(dataDateFmt.format(todayDate));
selectFrom = DSL.using(connection)
.select(Msg.MSG.MSGKEY, Msg.MSG.MSGSTS, Msg.MSG.MSGTIT,
DSL.concat(Msg.MSG.MSGTXT1, Msg.MSG.MSGTXT2, Msg.MSG.MSGTXT3),
DSL.date(Msg.MSG.MSGCDAT), Msg.MSG.MSGCTIM,
DSL.date(Msg.MSG.MSGRDAT), DSL.date(Msg.MSG.MSGEDAT),
Msg.MSG.MSGLUID)
.from(Msg.MSG)
.where(Msg.MSG.MSGFID.equal("SYS")
.and(Msg.MSG.MSGSTS.equal("NEW"))
.and(Msg.MSG.MSGTYP.equal("WEBF"))
.and(Msg.MSG.MSGGRP.equal("ALL"))
.and(Msg.MSG.MSGSDAT.lt(nowDate)));
最后一行的错误是“type字段中的method lt(Timestamp)不适用于参数(Date)”。我正在做一些与我所看到的非常相似的事情
# 1 楼答案
必须将
lt
中定义的相同数据类型传递给Msg.MSG.MSGSDAT
解决方案(不太通用,但有效):
关键是where子句中的
DSL.date(Msg.MSG.MSGSDAT)
和DSL.date(Msg.MSG.MSGEDAT)