English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

The <fmt:parseDate> tag

JSP Standard Tag Library

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

syntax format

<fmt:parseDate
   value="<string>"
   type="<string>"
   dateStyle="<string>"
   timeStyle="<string>"
   pattern="<string>"
   timeZone="<string>"
   parseLocale="<string>"
   var="<string>"
   scope="<string>"/>

attribute

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

attributedescription necessarydefault value
valuedate to be displayedyesnone
typeDATE, TIME, or BOTHNodate
dateStyleFULL, LONG, MEDIUM, SHORT, or DEFAULTNodefault
timeStyleFULL, LONG, MEDIUM, SHORT, or DEFAULTNodefault
patterncustom format patternNonone
timeZonetime zone for displaying dateNodefault timezone
varStore the variable name for formatting the dateNoDisplay on the page
ScopeStore the scope of the formatted log variableNoPage

Set the time format of the output we need.


Example Demonstration

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ 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>
<h2>Date Parsing:</h2>
<c:set var="now" value="20-10-2015" />
<fmt:parseDate value="${now}" var="parsedEmpDate" 
                              pattern="dd"-MM-yyyy" />
<p>The parsed date is: <c:out value="${parsedEmpDate}" /></p>
</body>
</html>

The above example runs as follows:

Date Parsing:
The parsed date is: Tue Oct 20 00:00:00 CST 2015

JSP Standard Tag Library