<fmt:formatdate value= "${isodate}" type= "both"/>
2004-5-31 23:59:59
<fmt:formatdate value= "${date}" type= "date"/>
2004-4-1
<fmt:formatdate value= "${isodate}" type= "Time"/>
23:59:59
<fmt:formatdate value= "${isodate}" type= "date" datestyle= "Default"/>
2004-5-31
<fmt:formatdate value= "${isodate}" type= "date" datestyle= "short"/>
04-5-31
<fmt:formatdate value= "${isodate}" type= "date" datestyle= "Medium"/>
2004-5-31
<fmt:formatdate value= "${isodate}" type= "date" datestyle= "Long"/>
May 31, 2004
<fmt:formatdate value= "${isodate}" type= "date" datestyle= "full"/>
Monday, May 31, 2004
<fmt:formatdate value= "${isodate}" type= "Time" timestyle= "Default"/>
23:59:59
<fmt:formatdate value= "${isodate}" type= "Time" timestyle= "short"/>
11:59
<fmt:formatdate value= "${isodate}" type= "Time" timestyle= "Medium"/>
23:59:59
<fmt:formatdate value= "${isodate}" type= "Time" timestyle= "Long"/>
11:59 P.M. 59 seconds.
<fmt:formatdate value= ' ${isodate} ' type= ' time ' timestyle= ' full '/>
11:59 P.M. 59 seconds CDT
<fmt:formatdate value= "${date}" type= "both" pattern= "eeee, MMMM D, yyyy HH:mm:ss Z"/>
Thursday, April 1, 2004 13:30:00-0600
<fmt:formatdate value= "${isodate}" type= "both" pattern= "D MMM yy, h:m:s a zzzz/>
315 months 04, 11:59:59 PM Central Daylight Time
Format mode:
D One day of the month. The date of one number does not have a leading zero.
One day of DD month. The date of a single number has a leading zero.
The abbreviated name of a day in the DDD week, defined in Abbreviateddaynames.
dddd the full name of the day of the week, defined in DayNames.
M-month numbers. A single number of months does not have a leading zero.
MM month number. A one-digit month has a leading zero.
The abbreviated name of the MMM month, defined in AbbreviatedMonthNames.
The full name of the MMMM month, defined in MonthNames.
Y does not contain the year of the era. If the year that does not contain the era is less than 10, the year is displayed with no leading zeros.
YY does not contain years of the era. If the year that does not contain the era is less than 10, the year with leading zeros is displayed.
YYYY includes the four-digit year of the era.
GG period or ERA. If the date to be formatted does not have an associated period or era string, the pattern is ignored.
H 12 Hour system. The number of hours in a single digit does not have a leading zero.
HH 12-hour hour. The number of hours in a single digit has a leading zero.
H 24 hour system. The number of hours in a single digit does not have a leading zero.
HH 24-hour hour. The number of hours in a single digit has a leading zero.
M minutes. The number of minutes in one digit does not have a leading zero.
MM minutes. The number of minutes in a single digit has a leading zero.
s seconds. A number of seconds does not have a leading zero.
SS seconds. The number of seconds in a single digit has a leading zero.
<fmt:formatdate value= "${xx}" pattern= "dd/mm/yyyy hh:mm aa"/> and
<fmt:formatdate value= "${xx}" pattern= "dd/mm/yyyy hh:mm aa"/> is different for 0-point display
Requires ${date} to be a date type <TD align= "center" ><script>document.write ("${l.inputdate}" if string. Substring (0, ));</script></td>
<%@ page language= "java" contenttype= "text/html; charset=gb18030 "%>
<%@ taglib uri= "http://java.sun.com/jsp/jstl/fmt" prefix= "FMT"%>
<%@ taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%>
<title>my JSP ' fmt.jsp ' starting page</title>
<body>
<c:set var= "Salary" value= "3540.2301"/>
<c:set var= "Total" value= "56225.2301"/>
<fmt:setlocale value= "en_US"/>
Currency:<fmt:formatnumber value= "${salary}" type= "Currency" currencycode= "USD"/><br>
Percent:<fmt:formatnumber value= "${salary/total}" type= "percent" maxfractiondigits= "4"/><br>
<jsp:usebean id= "Now" class= "Java.util.Date" ></jsp:useBean>
<fmt:setlocale value= "Zh_cn"/>
Full--><fmt:formatdate value= "${now}" type= "both" datestyle= "full" timestyle= "full"/><br>
Long--><fmt:formatdate value= "${now}" type= "both" datestyle= "long" timestyle= "Long"/><br>
Medium--><fmt:formatdate value= "${now}" type= "both" datestyle= "Medium" timestyle= "Medium"/><br>
Default--><fmt:formatdate value= "${now}" type= "both" datestyle= "default" timestyle= "Default"/><br>
Short--><fmt:formatdate value= "${now}" type= "both" datestyle= "short" timestyle= "short"/><br>
</body>
Today is: <fmt:formatdate value= "${now}" pattern= "G yyyy mm month DD Day E"/><br>
It is now: <fmt:formatdate value= "${now}" pattern= "a HH:mm:ss." S Z "/>
Results:
Today is: Ad October 19, 2007 Friday
It is now: PM 20:04:11.484 CST
<%@ taglib prefix= "C" uri= "Http://java.sun.com/jstl/core"%>
<%@ taglib prefix= "FMT" uri= "Http://java.sun.com/jstl/fmt"%>
<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 would thrown an exception. This page does no error handling.
Input Parameters:
date:2004/04/01:13:30:00 Java Format:thu Apr 13:30:00 CST 2004
isodate:20040531t235959 Java Format:mon may 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.
<fmt:formatdate value= "${date}" type= "date"/>
2004-4-1
<fmt:formatdate value= "${isodate}" type= "Time"/>
23:59:59
Attribute:datestyle; Optional. varies the date format.
<fmt:formatdate value= "${isodate}" type= "date" datestyle= "Default"/>
2004-5-31
<fmt:formatdate value= "${isodate}" type= "date" datestyle= "short"/>
04-5-31
<fmt:formatdate value= "${isodate}" type= "date" datestyle= "Medium"/>
2004-5-31
<fmt:formatdate value= "${isodate}" type= "date" datestyle= "Long"/>
May 31, 2004
<fmt:formatdate value= "${isodate}" type= "date" datestyle= "full"/>
Monday, May 31, 2004
Attribute:timestyle; Optional. varies the time format.
<fmt:formatdate value= "${isodate}" type= "Time" timestyle= "Default"/>
23:59:59
<fmt:formatdate value= "${isodate}" type= "Time" timestyle= "short"/>
11:59
<fmt:formatdate value= "${isodate}" type= "Time" timestyle= "Medium"/>
23:59:59
<fmt:formatdate value= "${isodate}" type= "Time" timestyle= "Long"/>
11:59 P.M. 59 seconds.
<fmt:formatdate value= ' ${isodate} ' type= ' time ' timestyle= ' full '/>
11:59 P.M. 59 seconds CDT
Attribute:pattern; Optional. Inidcates Date/time Custom Patterns.
<fmt:formatdate value= "${date}" type= "both" pattern= "eeee, MMMM D, yyyy HH:mm:ss Z"/>
Thursday, April 1, 2004 13:30:00-0600
<fmt:formatdate value= "${isodate}" type= "both" pattern= "D MMM yy, h:m:s a zzzz/>
315 months 04, 11:59:59 PM Central Daylight Time