简体   繁体   English

jooq 比较 2 个日期 - 它不喜欢 java.sql.Date

[英]jooq compare 2 dates - it does not like java.sql.Date

I am getting an error with the below code:我收到以下代码的错误:

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)));

The error I am getting for the last line is "The method lt(Timestamp) in the type Field is not applicable for the arguments (Date)".我在最后一行遇到的错误是“类型字段中的方法 lt(Timestamp) 不适用于参数 (Date)”。 I am doing something very similar to what I see here .我正在做的事情与我在这里看到的非常相似。

你必须通过相同的数据类型,以lt被定义Msg.MSG.MSGSDAT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM