Reputation: 844
I'm updating AJAX response using JSON taglib with this-
<json:property name="shipDate" value="Date is ${shippingDate}"></json:property>
But I want to format the shippingDate in "dd/MM/yyyy" format.
Is it possible to format date while setting json property? Thanks.
Upvotes: 0
Views: 920
Reputation: 9848
Here is how to format dates in JSP's using Java's tags:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatDate value="${shippingDate}" pattern="MMM dd, yyyy"/>
Update: You can also assign the output of to a JSP var and use elsewhere in your JSP like so:
<fmt:formatDate value="${shippingDate}" pattern="MMM dd, yyyy" var="formattedShippingData" />
<label>Shipping Date: </label> ${formattedShippingData}
Upvotes: 1