JSTL日期判断,JSTL时间判断

    设置时间spa

<%
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(Calendar.MONTH, 1);
%>
<fmt:formatDate value="<%=new Date() %>" var="nowmonth" pattern="yyyyMM"/>
<fmt:formatDate value="<%=cal.getTime() %>" var="nextmonth" pattern="yyyyMM"/>

而后在循环里面和当前时间判断orm

<c:choose>
    <c:when test="${fn:length(entity.conEnddate) eq 8}">
        <c:set var="dataDate" value="${fn:substring(entity.conEnddate, 0, 6)}" /><!-- 截取时间-->
        <c:choose>
            <c:when test="${dataDate eq nowmonth}"><!-- 当月-->
                <span style="color: red"><fs:property value="#entity.conEnddate" /></span>
            </c:when>
            <c:when test="${dataDate eq nextmonth}"><!-- 下个月-->
                <span style="color: blue"><fs:property value="#entity.conEnddate" /></span>
            </c:when>
            <c:otherwise><!-- 其余月-->
                <fs:property value="#entity.conEnddate" />
            </c:otherwise>
        </c:choose>
    </c:when>
    <c:otherwise>
        <fs:property value="#entity.conEnddate" />
    </c:otherwise>
</c:choose>
相关文章
相关标签/搜索