发布于 2015-08-17 14:50:46 | 91 次阅读 | 评论: 0 | 来源: 网络整理

<fmt:parseDate>标记用于解析日期。

属性:

<fmt:parseDate>标签具有以下属性:

属性 描述 必须 默认
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

模式属性提供的工作就像pattern属性为<fmt:formatDate>标签。然而,在分析的情况下,该模式属性告诉是什么格式,以及期望的解析器。

例子:


<%@ 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>

这将产生以下输出结果:

DATE PARSING:

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

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务