How to Formatting a Date in JSP

In JSP, to format a date into some pattern, you can use JSTL <fmt:formatDate>.

Let’s assumed that ${bean.createdDate} returns java.util.Date, here’s how to use it:

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/format" %>
...
<fmt:formatDate value="${bean.createdDate}" pattern="MMM-dd-yyyy / HH:mm:ss" />