< FMT: formatDate value = ”${isoDate}” type = “to both” / > The 2004-5-31 23:59:59
< FMT: formatDate value = ”${date}” type = “date” / > The 2004-4-1
< FMT: formatDate value = ”${isoDate}” type = “time” / > 23:59:59
< FMT: formatDate value = ”${isoDate}” type = “date” dateStyle = “default” / > The 2004-5-31
< FMT: formatDate value = ”${isoDate}” type = “date” dateStyle = “short” / > The 04-5-31
< FMT: formatDate value = ”${isoDate}” type = “date” dateStyle = “medium” / > The 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 PM
< FMT: formatDate value = ”${isoDate}” type = “time” timeStyle = “medium” / > 23:59:59
< FMT: formatDate value = ”${isoDate}” type = “time” timeStyle = “long” / > 11:59:59 p.m
< FMT: formatDate value = ”${isoDate}” type = “time” timeStyle = “full” / > CDT at 11:59 p.m
< 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 /> 31 May 04, 11:59:59 PM central daylight saving time
Format mode: D A certain day of the month. A single digit date has no leading zero. Dd A certain day of the month. A single digit date has a leading zero. Ddd The abbreviation for a day of the week, in AbbreviatedDayNames In the definition. Dddd The full name of a day of the week, in DayNames In the definition. M Monthly figures. A single digit month has no leading zero. MM Monthly figures. A single digit month has a leading zero. MMM Abbreviation of the month, in AbbreviatedMonthNames In the definition. MMMM The full name of the month, in MonthNames In the definition. Y A year that does not contain an era. If the year without an era is less than & PI; 10, shows years without leading zeros. Yy A year that does not contain an era. If the year without an era is less than & PI; 10, shows the year with leading zero. Yyyy A four-digit year that includes an era. Gg Period or epoch. If the date you want to format does not have an associated period or era string, the pattern is ignored. H 12 Hours by the hour. A single digit number of hours has no leading zero. Hh 12 Hours by the hour. The number of hours in a digit has a leading zero. H 24 Hours by the hour. A single digit number of hours has no leading zero. HH 24 Hours by the hour. The number of hours in a digit has a leading zero. M Minutes. The number of minutes of a digit has no leading zero. Mm Minutes. The number of minutes of a digit has a leading zero. S Seconds. The number of seconds of a digit has no leading zero. Ss Seconds. The number of seconds of a 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”/> The result is different for 0
You want ${date} to be of type date and if it’s String you use < Td align = “center” > < Script> Document. The write (” ${l.i nputDate} ”. The substring (0, 10)); < / 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” % > < Html> < Head> < Title> My JSP ‘fmt.jsp’ starting page< / title> < / head>
< 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> < Hr> < The 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> < / html>
Today is: < FMT :formatDate value=”${now}” pattern=“G yyyy year MM month dd day E”/> < Br> Now is: < FMT :formatDate value=”${now}” pattern=” HH:mm: ss.s z”/> Results: Today is: Friday, October 19, 2007 It’s now 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 will throw 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 The Tag Output Attribute: value; Required. Tag has no body. < FMT: formatDate value = ”${date}” type = “to both” / >
The 2004-4-1 13:30:00 < FMT: formatDate value = ”${isoDate}” type = “to both” / >
The 2004-5-31 23:59:59 Attribute: a type; Optional. Indicates what to print: date, time, or both. < FMT: formatDate value = ”${date}” type = “date” / >
The 2004-4-1 < FMT: formatDate value = ”${isoDate}” type = “time” / >
23:59:59 Attribute: dateStyle; Optional. The date format. < FMT: formatDate value = ”${isoDate}” type = “date” dateStyle = “default” / >
The 2004-5-31 < FMT: formatDate value = ”${isoDate}” type = “date” dateStyle = “short” / >
The 04-5-31 < FMT: formatDate value = ”${isoDate}” type = “date” dateStyle = “medium” / >
The 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. The time format. < FMT: formatDate value = ”${isoDate}” type = “time” timeStyle = “default” / >
23:59:59 < FMT: formatDate value = ”${isoDate}” type = “time” timeStyle = “short” / >
11:59 PM < FMT: formatDate value = ”${isoDate}” type = “time” timeStyle = “medium” / >
23:59:59 < FMT: formatDate value = ”${isoDate}” type = “time” timeStyle = “long” / >
11:59:59 p.m < FMT: formatDate value = ”${isoDate}” type = “time” timeStyle = “full” / >
CDT at 11:59 p.m Attribute: the 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 />
31 May 04, 11:59:59 p.m. Central daylight saving time