JSTL - Core <fmt:parseDate> Tag


Advertisements

The <fmt:parseDate> tag is used to parse dates.

Attribute

The <fmt:parseDate> tag has the following attributes −

Attribute Description Required Default
Value Date value to read (parse) No Body
type DATE, TIME, or BOTH No date
dateStyle FULL, LONG, MEDIUM, SHORT, or DEFAULT No Default
timeStyle FULL, LONG, MEDIUM, SHORT, or DEFAULT No Default
parseLocale Locale to use when parsing the date No Default locale
pattern Custom parsing pattern No None
timeZone Time zone of the parsed date No Default time zone
var Name of the variable to store the parsed date No Print to page
scope Scope of the variable to store the formatted date No page

A pattern attribute is provided that works just like the pattern attribute for the <fmt:formatDate> tag. However, in the case of parsing, the pattern attribute tells the parser what format to expect.

Example

<%@ 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:parseDate Tag</title>
   </head>

   <body>
      <h3>Date Parsing:</h3>
      
      <c:set var = "now" value = "20-10-2010" />
      <fmt:parseDate value = "${now}" var = "parsedEmpDate" pattern = "dd-MM-yyyy" />
      <p>Parsed Date: <c:out value = "${parsedEmpDate}" /></p>

   </body>
</html>

The above code will generate the following result −

Date Parsing:

Parsed Date: Wed Oct 20 00:00:00 GST 2010

jsp_standard_tag_library.htm

Useful Video Courses


Video

JSP, Servlet, JSLT + Hibernate: A complete guide

108 Lectures 11 hours

Chaand Sheikh

Video

Full Stack Java developer - Java + JSP + Restful WS + Spring

Best Seller

517 Lectures 57 hours

Chaand Sheikh

Video

Servlets and JSP Tutorial For Beginners!

41 Lectures 4.5 hours

Karthikeya T

Video

JSP and Servlets - The Complete Course

42 Lectures 5.5 hours

TELCOMA Global

Video

JSP and Servlets Bootcamp: Web Applications for Beginners

15 Lectures 3 hours

TELCOMA Global

Video

JSP (Java Server Pages) Certification Training

44 Lectures 15 hours

Uplatz

Advertisements