<fmt: formatdate value = "$ {isodate}" type = "ambos"/>
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 = "padrão"/>
2004-5-31
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "curto"/>
04-5-31
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "médio"/>
2004-5-31
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "long"/>
2004 年 5月 31 日
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "completo"/>
2004 年 5月 31 日 星期一
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "default"/>
23:59:59
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "curto"/>
下午 11:59
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "médio"/>
23:59:59
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "long"/>
下午 11 时 59 分 59 秒
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "completo"/>
下午 11 时 59 分 59 秒 CDT
<fmt: formatdate value = "$ {date}" type = "ambos" padrony = "eeee, mmmm d, yyyy hh: mm: ss z"/>
星期四, 四月 1, 2004 13:30:00 -0600
<fmt: formatdate value = "$ {isodate}" type = "ambos" padrony = "d mmm yy, h: m: sa zzzz/>
31 五月 04, 11:59:59 下午 中央夏令时 中央夏令时
格式模式
D 月中的某一天。一位数的日期没有前导零。
dd 月中的某一天。一位数的日期有一个前导零。
ddd 周中某天的缩写名称 , 在 abreviouddayNames 中定义。
DDDD 周中某天的完整名称 , 在 DayNames 中定义。
M 月份数字。一位数的月份没有前导零。
Mm 月份数字。一位数的月份有一个前导零。
Mmm 月份的缩写名称 , 在 abreviado em nomes 中定义。
Mmmm 月份的完整名称 , 在 MonthNames 中定义。
y 不包含纪元的年份。如果不包含纪元的年份小于 10 , 则显示不具有前导零的年份。
yy 不包含纪元的年份。如果不包含纪元的年份小于 10 , 则显示具有前导零的年份。
AAA AA
gg 时期或纪元。如果要设置格式的日期不具有关联的时期或纪元字符串 , 则忽略该模式。
H 12 小时制的小时。一位数的小时数没有前导零。
HH 12 小时制的小时。一位数的小时数有前导零。
H 24 小时制的小时。一位数的小时数没有前导零。
HH 24 小时制的小时。一位数的小时数有前导零。
m 分钟。一位数的分钟数没有前导零。
mm 分钟。一位数的分钟数有一个前导零。
s 秒。一位数的秒数没有前导零。
ss 秒。一位数的秒数有一个前导零。
<fmt: formatdate value = "$ {xx}" padrony = "dd/mm/yyyy hh: mm aa"/> 和
<fmt: formatdate value = "$ {xx}" padrony = "dd/mm/yyyy hh: mm aa"/> 对于 0 点显示的结果不一样
要求 $ {date} 为 Data 类型如果为 String 就用 <td align = "Center"> <Cript> document.write ("$ {l.inputDate}". /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> minha página de partida JSP 'fmt.jsp' </ititle>
</head>
<Body>
<c: set var = "salário" value = "3540.2301"/>
<c: set var = "total" value = "56225.2301"/>
<fmt: setLocale value = "en_us"/>
Moeda: <fmt: formatNumber value = "$ {salary}" type = "moeda" moedaCode = "USD"/> <br>
Porcentagem: <fmt: formatNumber value = "$ {salário/total}" type = "porcentagem" maxfractionDigits = "4"/> <br>
<HR>
<jsp: usebean id = "agora"> </jsp: usebean>
<fmt: setLocale value = "zh_cn"/>
Full-> <fmt: formatdate value = "$ {agora}" type = "ambos" dataStySyle = "Full" Timestyle = "Full"/> <br>
long-> <fmt: formatdate value = "$ {agora}" type = "ambos" dataStySyle = "long" timestyle = "long"/> <br>
Medium-> <fmt: formatdate value = "$ {agora}" type = "ambos" dataStySyle = "Medium" Timestyle = "Medium"/> <br>
padrão-> <fmt: formatdate value = "$ {agora}" type = "ambos" dataStySyle = "padrão" timestyle = "padrão"/> <br>
Short-> <fmt: formatdate value = "$ {agora}" type = "ambos" dataStySyle = "Short" Timestyle = "Short"/> <br>
</body>
</html>
今天是: <fmt: formatdate value = "$ {agora}" padrony = "g yyyy 年 mm 月 dd 日 e"/> <br>
现在是: <fmt: formatdate value = "$ {agora}" padrony = "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" padrony = "yyyy/mm/dd: hh: mm: ss>
<fmt: parsedate value = "$ {param.isodate}" var = "isodate" padrony = "yyyymmdd'hhhmmss">
Os parâmetros de entrada devem corresponder aos padrões, ou o JSP lançará uma exceção. Esta página não faz manuseio de erros.
Parâmetros de entrada:
Data: 2004/04/01: 13: 30: 00 Java Formato: Qui 01 de abril 13:30:00 CST 2004
ISODATE: 20040531T235959 Java Formato: Seg 31 de maio 23:59:59 CDT 2004
Datas
Saída de tags
Atributo: valor; obrigatório. Tag não tem corpo.
<fmt: formatdate value = "$ {date}" type = "ambos"/>
2004-4-1 13:30:00
<fmt: formatdate value = "$ {isodate}" type = "ambos"/>
2004-5-31 23:59:59
Atributo: tipo; opcional. Indica o que imprimir: data, hora ou ambos.
<fmt: formatdate value = "$ {date}" type = "date"/>
2004-4-1
<fmt: formatdate value = "$ {isodate}" type = "time"/>
23:59:59
Atributo: Datestyle; opcional. Varia o formato da data.
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "padrão"/>
2004-5-31
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "curto"/>
04-5-31
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "médio"/>
2004-5-31
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "long"/>
2004 年 5月 31 日
<fmt: formatdate value = "$ {isodate}" type = "date" datestyle = "completo"/>
2004 年 5月 31 日 星期一
Atributo: Timestyle; opcional. Varia o formato de tempo.
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "default"/>
23:59:59
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "curto"/>
下午 11:59
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "médio"/>
23:59:59
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "long"/>
下午 11 时 59 分 59 秒
<fmt: formatdate value = "$ {isodate}" type = "time" timestyle = "completo"/>
下午 11 时 59 分 59 秒 CDT
Atributo: padrão; opcional. Padrões personalizados Data/Hora Inidcates.
<fmt: formatdate value = "$ {date}" type = "ambos" padrony = "eeee, mmmm d, yyyy hh: mm: ss z"/>
星期四, 四月 1, 2004 13:30:00 -0600
<fmt: formatdate value = "$ {isodate}" type = "ambos" padrony = "d mmm yy, h: m: sa zzzz/>
31 五月 04, 11:59:59 下午 中央夏令时 中央夏令时