Latest web development tutorials

<Fmt: parseDate> tag

JSP Standard Tag Library JSP Standard Tag Library

<Fmt: parseDate> tag for parsing date.

Syntax

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

Attributes

<Fmt: parseDate> tag has the following attributes:

Attributes description If necessary Defaults
value To date display Yes no
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
pattern Custom format mode no no
timeZone Time zone display date no Default time zone
var Variable names store formatted dates no Displayed on the page
scope Range variable storage format log no page

We need to set the time format attribute output.



Examples Demo

<%@ 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 标签</title>
</head>
<body>
<h3>日期解析:</h3>
<c:set var="now" value="20-10-2015" />

<fmt:parseDate value="${now}" var="parsedEmpDate" 
                              pattern="dd-MM-yyyy" />
<p>解析后的日期为: <c:out value="${parsedEmpDate}" /></p>

</body>
</html>

Examples of the above operating results:

日期解析:

解析后的日期为: Tue Oct 20 00:00:00 CST 2015

JSP Standard Tag Library JSP Standard Tag Library