This tag is Just Use to Display The Date and time In unique formats like in long style, Medium style. The style to represent date in “yyyy-dd-mm” format. As per other tags the required attributes are also used in this tag.
<%@ taglib prefix=”c” uri=”http://java.sun.com/jsp/jstl/core” %>
<%@ taglib prefix=”fmt” uri=”http://java.sun.com/jsp/jstl/fmt” %>
<html>
<head>
<title>JSTL <fmt:dateNumber> Tag</title>
</head>
<body>
<b><center><h3>Date Format in JSTL</h3></b></center>
<c:set var=”dt” value=”<%=new java.util.Date()%>” />
<b><center><p>Date as Formated(1): <fmt:formatDate type=”time”
value=”${dt}” /></p></center></b>
<b><center><p>Date as Formated(2): <fmt:formatDate type=”date”
value=”${dt}” /></p></center></b>
<b><center><p>Date as Formated (3): <fmt:formatDate type=”both”
value=”${dt}” /></p></center></b>
<b><center><p>Date as Formated (4): <fmt:formatDate type=”both”
dateStyle=”long” timeStyle=”long”
value=”${dt}” /></p></center></b>
<b><center><p>Date as Formated (5): <fmt:formatDate pattern=”yyyy-MM-dd”
value=”${dt}” /></p></center></b>
</body>
</html>
This program is just as a demo of that how to display the system date & time in unique formats as required first we call the JSTL tag library codes. That will help to access the required functions. Then after declaring mandatory variables and tags that been use to represent output on web browser the java utility package also been called while output criteria as for display on browser. Here after every command we use the condition that how the date and time will display like medium, long or in pattern way.