码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-04-06 02:02:52      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

     效果图:

     技术分享

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>

 

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

标签:

原文地址:http://www.cnblogs.com/banxian-yi/p/5357571.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!