CodesJava

Easy learning with example program codes

JSTL fmt:parseDate Formatting Tag

The JSTL <fmt:parseDate> Formatting Tag is used for parsing the dates.

Syntax:

<fmt:parseDate value=”val” otherattributes />

fmt:parseDate tag attributes:

AttributeDescriptionRequired
valueDate value to read or parse.Yes
typeDATE, TIME, or BOTH.No
dateStyleFULL, LONG, MEDIUM, SHORT, DEFAULT.No
timeStyleFULL, LONG, MEDIUM, SHORT, DEFAULT.No
parseLocaleLocale to use when parsing the date.No
patternIt specify the custom parsing pattern.No
timeZoneIt specify the time zone of the parsed date.No
varIt specify the name of the variable to store the parsed date.No
scopeIt 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" %>
 
<html>
	<head>
		<title>fmt:parseDate JSTL formatting tag example</title>
	</head>
	<body>
		<c:set var="currentDate" value="2014-06-14" />
		<fmt:parseDate value="${currentDate}" 
                      var="parsedDate" pattern="yyyy-MM-dd" />
		Current date after parsing: <br/>	
		<c:out value="${parsedDate}"/>
	</body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>test.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 46
 
Download this example.
 
Next Topic: JSTL fmt:bundle Formatting Tag with example.
Previous Topic: JSTL fmt:formatDate Formatting Tag with example.

 

Please follow and like us:
error
Posted in JSP   








Copyright © 2019 CodesJava DMCA.com Protection Status