設置時間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>