关于查询时间的几个问题?

     效果图:

     

1、xml中sql日期查询写法:

<if test="beginInDate != null and beginInDate != ''">
     AND t.CREATE_DATE <![CDATA[ >= #{beginInDate} ]]>
</if>
<if test="endInDate != null and endInDate != ''">
     AND t.CREATE_DATE <![CDATA[ <= #{endInDate} ]]>
</if>

2、如何设置结束时间为23:59:59?

controller中的list里:

if(bean.getEndInDate()!=null && !bean.getEndInDate().equals("")){
     Date result = PublicUtils.getLastTime(bean.getEndInDate());
     bean.setEndInDate(result);}

调用公共类的方法:

    /**
     * 返回日期最后时间:yyyy-MM-dd 23:59:59
     */
    public static Date getLastTime(Date currentDate){
        Date result = new Date();
        if(currentDate==null){
            return result;
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            String t = sdf.format(currentDate)+" 23:59:59";
            result = df.parse(t);
        } catch (ParseException e) {
            return result;
        }
        return result;
    }

3.日期查询页面中的写法:

 <li><label>创建日期:</label>
        <input id="begindate" name="beginInDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
        value="<fmt:formatDate value="${toolSet.beginInDate}" pattern="yyyy-MM-dd"/>"
             onclick="WdatePicker({maxDate:'#F{$dp.$D(\'enddate\')}'})"/> -                
        <input id="enddate" name="endInDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
             value="<fmt:formatDate value="${toolSet.endInDate}" pattern="yyyy-MM-dd"/>"
                    onclick="WdatePicker({minDate:'#F{$dp.$D(\'begindate\')}'})"/>
</li>

 

转载于:https://www.cnblogs.com/banxian-yi/p/5357571.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值