码迷,mamicode.com
首页 > 编程语言 > 详细

Java mybatis日期比较查询

时间:2021-06-02 19:42:04      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:led   temp   font   osc   turn   name   tar   resultmap   show   

public static SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
public static SimpleDateFormat format1 = new SimpleDateFormat(
"yyyyMMdd HH:mm:ss");



/**
* 得到指定日期的一天的的最后时刻23:59:59
*
* @param date
* @return
*/
public static Date getFinallyDate(Date date) {
String temp = format.format(date);
temp += " 23:59:59";

try {
return format1.parse(temp);
} catch (Exception e) {
return null;
}
}

/**
* 得到指定日期的一天的开始时刻00:00:00
*
* @param date
* @return
*/
public static Date getStartDate(Date date) {
String temp = format.format(date);
temp += " 00:00:00";

try {
return format1.parse(temp);
} catch (Exception e) {
return null;
}
}


<sql id="selectAcShareinfoScoreHistoryVo">
select share_id,inout_account_type, userName, phone, user_uuid, userName_to, phone_to,
type, del_flag, create_by, create_time,
update_by, update_time, score, score_show from ac_shareinfo_score_history
</sql>

<select id="selectAcShareinfoScoreHistoryList" parameterType="AcShareinfoScoreHistory" resultMap="AcShareinfoScoreHistoryResult">
<include refid="selectAcShareinfoScoreHistoryVo"/>
<where>
<if test="username != null and username != ‘‘"> and userName like concat(‘%‘, #{username}, ‘%‘)</if>
<if test="phone != null and phone != ‘‘"> and phone = #{phone}</if>
<if test="userUuid != null and userUuid != ‘‘"> and user_uuid = #{userUuid}</if>
<if test="usernameTo != null and usernameTo != ‘‘"> and userName_to = #{usernameTo}</if>
<if test="phoneTo != null and phoneTo != ‘‘"> and phone_to = #{phoneTo}</if>
<if test="type != null and type != ‘‘"> and type = #{type}</if>
<if test="score != null and score != ‘‘"> and score = #{score}</if>
<if test="scoreShow != null and scoreShow != ‘‘"> and score_show = #{scoreShow}</if>
<if test="inout_account_type != null and inout_account_type != ‘‘"> and inout_account_type = #{inout_account_type}</if>

<if test="createTime != null">
AND date_format(create_time,‘%y%m%d‘) >= date_format(#{createTime},‘%y%m%d‘)
</if>
<if test="updateTime != null">
AND date_format(#{updateTime},‘%y%m%d‘) >= date_format(create_time,‘%y%m%d‘)
</if>

</where>
</select>

Java mybatis日期比较查询

标签:led   temp   font   osc   turn   name   tar   resultmap   show   

原文地址:https://www.cnblogs.com/LowKeyCXY/p/14836000.html

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