我要用判断sql查到的时间距离现在是否3天后。

String queryString = "SELECT c.couponname,c.couponfee/100,c.pic1_path,date_format(c.endtime,'%Y-%c-%d') as endTime FROM couponpublish c,couponpool s WHERE s.pubid=c.pubid AND s.owner='"+userId+"' ";
String whereString="";
//优惠卷类别 1.可用;2.历史
if(type==1){
whereString=whereString+" and ( '"+nowTime+"' between c.starttime and c.endtime ) and s.status=3 ";
}else{
whereString=whereString+" and (( '"+nowTime+"' > c.endtime ) or s.status>3 )";
}

        String orderString=" order by c.updatetime ";

        int offset=PagerUtil.getOffset(Integer.valueOf(page),Integer.valueOf(rows));
        List<Map> list=super.findListbySqlReturnMapByPage(queryString+whereString, offset, Integer.valueOf(rows));

        System.out.println(list);        
        attributes.put("coupons", list);

    }else{
        throw new InterfaceException(new ErrorBean(ErrorCode.USER_NO_LOGIN));
    }

    return  attributes;

怎么写判断当前时间是否是查到的时间的三天前,然后写在list里

看下sql的datediff函数,或者读取出时间,转成date类,调用getTime()方法,返回long值再比较

select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))) as spanDays from dual
上面的处理是求当前日期到07年那天的天数,你把条件改成>3天的就行了

首先判断年月相等,,然后判断天数的问题,,