您的位置:首页 > Web前端 > JavaScript

JSP 比较时间字段与当前时间大小进行相关显示

2017-12-03 10:23 483 查看
endTime 是我数据字段的名称.为date类型

方法1:

<c:set var="currentTime" value="<%= new Date()%>"></c:set>
<c:if test="${currentTime.time > act.endTime.time}">    相关显示....
</c:if>


说明:如果是date类型的话需要转化为毫秒。 格式为 ${time1.time}

方法2:

<c:set var="currentTime" value="<%= System.currentTimeMillis()%>"></c:set>
<c:if test="${currentTime> act.endTime.time}">    相关显示....
</c:if>


说明: 因为我设置的当前时间为毫秒值。所以直接可以用就行。

方法3:

<% request.setAttribute("currentTime", new Date()); %>
<c:if test="${currentTime> act.endTime.time}">
相关显示....
</c:if>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息