<fmt: formatdate value = "$ {isodate}" type = "à la fois" />
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 = "mediad" />
2004-5-31
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "long" />
2004 年 5月 31 日
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "full" />
2004 年 5月 31 日 星期一
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "default" />
23:59:59
<fmt: formatdate value = "$ {isodate}" type = "time" TimeSyle = "short" />
下午 11:59
<fmt: formatdate value = "$ {isodate}" type = "time" TimeSyle = "medium" />
23:59:59
<fmt: formatdate value = "$ {isodate}" type = "time" TimeSyle = "long" />
下午 11 时 59 分 59 秒
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "full" />
下午 11 时 59 分 59 秒 CDT
<fmt: formatdate value = "$ {date}" type = "à la fois" pattern = "eeee, mmmm d, yyyy hh: mm: ss z" />
星期四, 四月 1, 2004 13:30:00 -0600
<fmt: formatdate value = "$ {isoDate}" type = "à la fois" Pattern = "d mmm yy, h: m: sa zzzz />
31 五月 04, 11:59:59 下午 中央夏令时 中央夏令时
:
D 月中的某一天。一位数的日期没有前导零。
dd 月中的某一天。一位数的日期有一个前导零。
ddd 周中某天的缩写名称 , 在 Abréviation de jours
dddd 周中某天的完整名称 , 在 Names de jour 中定义。
M 月份数字。一位数的月份没有前导零。
Mm 月份数字。一位数的月份有一个前导零。
Mmm 月份的缩写名称 , 在 Abréviation de mois
Mmmm 月份的完整名称 , 在 Names mensuels 中定义。
y 不包含纪元的年份。如果不包含纪元的年份小于 10 , 则显示不具有前导零的年份。
yy 不包含纪元的年份。如果不包含纪元的年份小于 10 , 则显示具有前导零的年份。
yyyy 包括纪元的四位数的年份。
gg 时期或纪元。如果要设置格式的日期不具有关联的时期或纪元字符串 , 则忽略该模式。
h 12 小时制的小时。一位数的小时数没有前导零。
HH 12 小时制的小时。一位数的小时数有前导零。
H 24 小时制的小时。一位数的小时数没有前导零。
HH 24 小时制的小时。一位数的小时数有前导零。
M 分钟。一位数的分钟数没有前导零。
mm 分钟。一位数的分钟数有一个前导零。
S 秒。一位数的秒数没有前导零。
SS 秒。一位数的秒数有一个前导零。
<fmt: formatdate value = "$ {xx}" pattern = "dd / mm / yyyy hh: mm aa" /> 和
<fmt: formatdate value = "$ {xx}" pattern = "dd / mm / yyyy hh: mm aa" /> 对于 0 点显示的结果不一样
要求 $ {date} 为 Date 类型如果为 String 就用 <td align = "Center"> <script> document.write ("$ {l.inputdate}". 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>
<adal>
<Title> My JSP 'FMT.JSP' Page de départ </TITAL>
</ head>
<body>
<c: set var = "salaire" value = "3540.2301" />
<c: set var = "total" value = "56225.2301" />
<fmt: setlocale value = "en_us" />
devise: <fmt: formatNumber value = "$ {salaire}" type = "Currency" CurrencyCode = "USD" /> <br>
pourcentage: <fmt: formatNumber value = "$ {salaire / total}" type = "%" maxFractionDigits = "4" /> <br>
<hr>
<jsp: usebean id = "maintenant"> </ jsp: useBean>
<fmt: setlocale value = "zh_cn" />
Full -> <fmt: formatdate value = "$ {maintenant}" type = "à la fois" datestyle = "complet" timestyle = "full" /> <br>
long -> <fmt: formatdate value = "$ {maintenant}" type = "à la fois" datestyle = "long" timestyle = "long" /> <br>
Medium -> <fmt: formatdate value = "$ {maintenant}" type = "à la fois" datestyle = "medium" timestyle = "mediad" /> <br>
Default -> <fmt: formatdate value = "$ {maintenant}" type = "à la fois" datestyle = "default" Timestyle = "Default" /> <br>
Short -> <fmt: formatdate value = "$ {maintenant}" type = "à la fois" datestyle = "short" timestyle = "short" /> <br>
</docy>
</html>
今天是: <fmt: formatdate value = "$ {maintenant}" pattern = "g yyyy 年 mm 月 dd 日 e" /> <br>
现在是: <fmt: formatdate value = "$ {maintenant}" Pattern = "A HH: MM: SS.S Z" />
结果:
今天是: 公元 2007 年 10月 19日 星期五
现在是: 下午 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 = "yyyymmdT'hhmmss">
Les paramètres d'entrée doivent correspondre aux modèles, ou le JSP lancera une exception. Cette page ne fait aucune gestion des erreurs.
Paramètres d'entrée:
Date: 2004/04/01: 13: 30: 00 Format Java: jeu 01 avril 13:30:00 CST 2004
Isodate: 20040531t235959 Format Java: lun 31 mai 23:59:59 CDT 2004
Dates
Étiquette de sortie
Attribut: valeur; requis. Le tag n'a pas de corps.
<fmt: formatdate value = "$ {date}" type = "les deux" />
2004-4-1 13:30:00
<fmt: formatdate value = "$ {isodate}" type = "à la fois" />
2004-5-31 23:59:59
Attribut: type; facultatif. Indique quoi imprimer: date, heure ou les deux.
<fmt: formatdate value = "$ {date}" type = "date" />
2004-4-1
<fmt: formatdate value = "$ {isodate}" type = "time" />
23:59:59
Attribut: Datestyle; facultatif. Varie le format de date.
<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 = "mediad" />
2004-5-31
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "long" />
2004 年 5月 31 日
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "full" />
2004 年 5月 31 日 星期一
Attribut: Immatage; facultatif. Varie le format de temps.
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "default" />
23:59:59
<fmt: formatdate value = "$ {isodate}" type = "time" TimeSyle = "short" />
下午 11:59
<fmt: formatdate value = "$ {isodate}" type = "time" TimeSyle = "medium" />
23:59:59
<fmt: formatdate value = "$ {isodate}" type = "time" TimeSyle = "long" />
下午 11 时 59 分 59 秒
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "full" />
下午 11 时 59 分 59 秒 CDT
Attribut: modèle; facultatif. INIDCATE DATE / TEUL MOTRES CUSTOM.
<fmt: formatdate value = "$ {date}" type = "à la fois" pattern = "eeee, mmmm d, yyyy hh: mm: ss z" />
星期四, 四月 1, 2004 13:30:00 -0600
<fmt: formatdate value = "$ {isoDate}" type = "à la fois" Pattern = "d mmm yy, h: m: sa zzzz />
31 五月 04, 11:59:59 下午 中央夏令时 中央夏令时