<fmt: formatDate value = "$ {isodate}" type = "ambas"/>
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" dataStyle = "default"/>
2004-5-31
<fmt: formatDate value = "$ {isodate}" type = "date" dataStyle = "Short"/>
04-5-31
<fmt: formatDate value = "$ {isodate}" type = "date" dataStyle = "Medium"/>
2004-5-31
<fmt: formatDate value = "$ {isodate}" type = "date" dataStyle = "long"/>
2004 年 5月 31 日
<fmt: formatDate value = "$ {isodate}" type = "date" dataStyle = "full"/>
2004 年 5月 31 日 星期一
<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 = "mediano"/>
23:59:59
<fmt: formatDate value = "$ {isodate}" type = "time" timestyle = "long"/>
下午 11 时 59 分 59 秒
<fmt: formatDate value = "$ {isodate}" type = "time" timestyle = "full"/>
下午 11 时 59 分 59 秒 CDT
<fmt: formatDate value = "$ {date}" type = "ambas" patrón = "eeee, mmmm d, yyyy hh: mm: ss z"/>
星期四, 四月 1, 2004 13:30:00 -0600
<fmt: formatDate value = "$ {isodate}" type = "ambos" patrón = "d mmm yy, h: m: sa zzzz/>
31 五月 04, 11:59:59 下午 中央夏令时
格式模式 :
D 月中的某一天。一位数的日期没有前导零。
DD 月中的某一天。一位数的日期有一个前导零。
DDD 周中某天的缩写名称 , 在 Abreviado Daynames 中定义。
DDDD 周中某天的完整名称 在 在 在 Daynames 中定义。
M 月份数字。一位数的月份没有前导零。
Mm 月份数字。一位数的月份有一个前导零。
Mmm 月份的缩写名称 在 在 Abreviado Monthnames 中定义。
Mmmm 月份的完整名称 在 在 在 Mes mensuales 中定义。
y 不包含纪元的年份。如果不包含纪元的年份小于 10 , 则显示不具有前导零的年份。
yy 不包含纪元的年份。如果不包含纪元的年份小于 10 , 则显示具有前导零的年份。
Yyyy 包括纪元的四位数的年份。
GG 时期或纪元。如果要设置格式的日期不具有关联的时期或纪元字符串 则忽略该模式。 则忽略该模式。
H 12 小时制的小时。一位数的小时数没有前导零。
HH 12 小时制的小时。一位数的小时数有前导零。
H 24 小时制的小时。一位数的小时数没有前导零。
HH 24 小时制的小时。一位数的小时数有前导零。
M 分钟。一位数的分钟数没有前导零。
mm 分钟。一位数的分钟数有一个前导零。
S 秒。一位数的秒数没有前导零。
SS 秒。一位数的秒数有一个前导零。
<fmt: formatDate value = "$ {xx}" patrón = "dd/mm/yyyy hh: mm aa"/> 和
<fmt: formatDate value = "$ {xx}" patrón = "dd/mm/yyyy hh: mm aa"/> 对于 0 点显示的结果不一样
要求 $ {date} 为 fecha 类型如果为 cadena 就用 <td align = "center"> <script> document.write ("$ {l.inputdate}". Substring (0, 10)); </script> < /TD>
<%@ page lenguaje = "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>
<Evista>
<title> my jsp 'fmt.jsp' página inicial </title>
</ablo>
<Body>
<c: set var = "salario" valor = "3540.2301"/>
<c: set var = "total" valor = "56225.2301"/>
<fmt: setLocale value = "en_us"/>
moneda: <fmt: formatnumber value = "$ {salary}" type = "Currency" CurrencyCode = "USD"/> <br>
porcentaje: <fmt: formatnumber value = "$ {salary/total}" type = "porcentaje" maxFractionDigits = "4"/> <br>
<hr>
<jsp: useBean id = "ahora"> </jsp: useBean>
<fmt: setLocale value = "zh_cn"/>
Full-> <fmt: formatDate value = "$ {ahora}" type = "ambas" dataTyle = "full" timeStyle = "full"/> <br>
Long-> <fmt: formatDate value = "$ {ahora}" type = "ambas" dataTyle = "long" timeStyle = "long"/> <br>
Medium-> <fmt: formatDate value = "$ {ahora}" type = "ambas" dataTyle = "Medium" timSestyle = "Medium"/> <br>
predeterminado-> <fmt: formatDate value = "$ {ahora}" type = "ambas" dataTyle = "default" timeStyle = "default"/> <br>
Short-> <fmt: formatDate value = "$ {ahora}" type = "Ambos" dataTyle = "Short" TimeStyle = "Short"/> <br>
</body>
</html>
今天是: <fmt: formatDate value = "$ {ahora}" patrón = "g yyyy 年 mm 月 dd 日 e"/> <br>
现在是: <fmt: formatDate value = "$ {ahora}" patrón = "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" patrón = "yyyy/mm/dd: hh: mm: ss>
<fmt: parsedate value = "$ {param.isodate}" var = "isodate" patrón = "yyyymmdd't'hhmmss">
Los parámetros de entrada deben coincidir con los patrones, o el JSP arrojará una excepción. Esta página no hace manejo de errores.
Parámetros de entrada:
Fecha: 2004/04/01: 13: 30: 00 Formato de Java: Jue 01 de abril 13:30:00 CST 2004
Isodate: 20040531T235959 Formato Java: lunes 31 de mayo 23:59:59 CDT 2004
Fechas
Salida de la etiqueta
Atributo: valor; requerido. La etiqueta no tiene cuerpo.
<fmt: formatDate value = "$ {date}" type = "ambos"/>
2004-4-1 13:30:00
<fmt: formatDate value = "$ {isodate}" type = "ambas"/>
2004-5-31 23:59:59
Atributo: tipo; opcional. Indica qué imprimir: fecha, hora o ambos.
<fmt: formatDate value = "$ {date}" type = "date"/>
2004-4-1
<fmt: formatDate value = "$ {isodate}" type = "time"/>
23:59:59
Atributo: estilo data; opcional. Varía el formato de fecha.
<fmt: formatDate value = "$ {isodate}" type = "date" dataStyle = "default"/>
2004-5-31
<fmt: formatDate value = "$ {isodate}" type = "date" dataStyle = "Short"/>
04-5-31
<fmt: formatDate value = "$ {isodate}" type = "date" dataStyle = "Medium"/>
2004-5-31
<fmt: formatDate value = "$ {isodate}" type = "date" dataStyle = "long"/>
2004 年 5月 31 日
<fmt: formatDate value = "$ {isodate}" type = "date" dataStyle = "full"/>
2004 年 5月 31 日 星期一
Atributo: estilo de tiempo; opcional. Varía el formato de tiempo.
<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 = "mediano"/>
23:59:59
<fmt: formatDate value = "$ {isodate}" type = "time" timestyle = "long"/>
下午 11 时 59 分 59 秒
<fmt: formatDate value = "$ {isodate}" type = "time" timestyle = "full"/>
下午 11 时 59 分 59 秒 CDT
Atributo: Patrón; opcional. Inidcada Patrones personalizados de fecha/hora.
<fmt: formatDate value = "$ {date}" type = "ambas" patrón = "eeee, mmmm d, yyyy hh: mm: ss z"/>
星期四, 四月 1, 2004 13:30:00 -0600
<fmt: formatDate value = "$ {isodate}" type = "ambos" patrón = "d mmm yy, h: m: sa zzzz/>
31 五月 04, 11:59:59 下午 中央夏令时