日期:2014-05-16  浏览次数:20379 次

【转载】jstl中的日期格式化-fmt.tld使用

转载http://917a.blog.163.com/blog/static/71570022200991532754805/

?

jstl中的日期格式化

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

?

<fmt:formatDate var="articleDate" value="${article.adate }" pattern="MM-dd"/>${articleDate }

<fmt:parseDate value="${param.date}" var="date" pattern="yyyy/MM/dd:HH:mm:ss>

<fmt:parseDate value="${param.isoDate}" var="isoDate" pattern="yyyyMMdd'T'HHmmss">

The input parameters must match the patterns, or the JSP will thrown an exception. This page does no error handling.

Input parameters:

Date:??? 2004/04/01:13:30:00?? Java format: Thu Apr 01 13:30:00 CST 2004

isoDate: 20040531T235959?????? Java format: Mon May 31 23:59:59 CDT 2004

Dates

Tag Output

Attribute: value; required. Tag has no body.

<fmt:formatDate value="${date}" type="both"/>

?2004-4-1 13:30:00?

?

<fmt:formatDate value="${isoDate}" type="both"/>

?2004-5-31 23:59:59?

?

Attribute: type; optional. Indicates what to print: date, time, or both.