JSTL fmt:formatDate Formatting Tag

The JSTL <fmt:formatDate> Formatting Tag is used for formatting the dates.

Syntax:

<fmt:formatDate value=”val” otherattributes>

fmt:formatDate tag attributes:

Attribute Description Required
value It specify the date value to display. Yes
type DATE, TIME, or BOTH No
dateStyle FULL, LONG, MEDIUM, SHORT, DEFAULT. No
timeStyle FULL, LONG, MEDIUM, SHORT, DEFAULT. No
pattern It specify the custom formatting pattern. No
timeZone It specify the time zone of the displayed date. No
var It specify the name of the variable to store the formatted date. No
scope It specify the scope of the variable to store the formatted date. No

Example:

test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>


	
		fmt:formatDate JSTL formatting tag example
	
	
	  
	  Current date after setting type attribute to date: 

Current date after setting type attribute to time:

Current date after setting type attribute to both:

Current date after setting pattern attribute:

web.xml


	
  
          test.jsp
  	


Output:

jsp example 45
 
Download this example.
 
Next Topic: JSTL fmt:parseDate Formatting Tag with example.
Previous Topic: JSTL fmt:parseNumber Formatting Tag with example.