jstl
pubDate在实体中为String
<c:set var="currentTime" value="<%=System.currentTimeMillis()%>" />
<c:forEach items="${inNewsList }" var="in" end="5" varStatus="vsIn" >
<fmt:parseDate value="${in.pubDate}" var="date"/>
<c:if test="${currentTime - date.time <= 3600*24*1000*3}" >
<img src='${ctx}/static/images/newflash.gif' width="29" height="9" />
</c:if>
</c:forEach>
pubDate在实体中为Date
<pre name="code" class="html"><c:set var="currentTime" value="<%=System.currentTimeMillis()%>" />
<c:forEach items="${inNewsList }" var="in" end="5" varStatus="vsIn" >
<c:if test="${currentTime - in.pubDate.time <= 3600*24*1000*3}" >
<img src='${ctx}/static/images/newflash.gif' width="29" height="9" />
</c:if>
</c:forEach>
Java
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, -3);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String now3 = format.format(calendar.getTime());
map.put("now3", now3);
Freemaker
<#if now3?date("yyyy-MM-dd") < pagelist.addtime[0..10]?date("yyyy-MM-dd")>
<img src="/html/images/new.jpg" />
</#if>