Monday, April 21, 2014

Date manipulation in JSP JSTL

Here is the code snippet for adding to days to the current day  and display it in a JSP using JSTL. Here 48 indicates 2 days (2*24 hours = 48 hours)

<jsp:usebean class="java.util.Date" id="dateToday">

<c:set value="${dateToday.time + 48*60*60*1000}" var="twoDaysInSeconds">

<c:set property="time" target="${dateToday}" value="${twoDaysInSeconds}">      

<fmt:formatdate datestyle="short" pattern="MM/dd/yyyy" type="date" value="${dateToday}" var="expDate">

</fmt:formatdate></c:set></c:set></jsp:usebean>

No comments:

Post a Comment