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="" %>

<%@ taglib prefix="fmt" uri="" %>



           <title>JSTL &lt;fmt:dateNumber&gt; Tag</title>



              <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>



       JSTL Tag <fmt:formatDate>

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.

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.