<fmt:formatDate>标记用于在各种不同的方式来格式化日期

属性:

<fmt:formatDate>标签具有以下属性:

属性 描述 必需 默认值
value 要显示的日期值 Yes None
type DATE, TIME, or BOTH No date
dateStyle FULL, LONG, MEDIUM, SHORT, or DEFAULT No default
timeStyle FULL, LONG, MEDIUM, SHORT, or DEFAULT No default
pattern Custom formatting pattern No None
timeZone Time zone of the displayed date No Default time zone
var Name of the variable to store the formatted date No Print to page
scope Scope of the variable to store the formatted date No page

pattern属性来指定更精确的处理日期:

Code Purpose Sample

G

The era designator

AD

y

The year

2002

M

The month

April & 04

d

The day of the month

20

h

The hour(12-hour time)

12

H

The hour(24-hour time)

0

m

The minute

45

s

The second

52

S

The millisecond

970

E

The day of the week

Tuesday

D

The day of the year

180

F

The day of the week in the month

2 (2nd Wed in month)

w

The week in the year

27

W

The week in the month

2

a

The a.m./p.m. indicator

PM

k

The hour(12-hour time)

24

K

The hour(24-hour time)

0

z

The time zone

Central Standard Time

'

 

The escape for text

''

 

The single quote

例子:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <html>
<head>
<title>JSTL fmt:dateNumber Tag - www.yiibai.com</title>
</head>
<body>
<h3>Number Format:</h3>
<c:set var="now" value="<%=new java.util.Date()%>" /> <p>Formatted Date (1): <fmt:formatDate type="time"
value="${now}" /></p>
<p>Formatted Date (2): <fmt:formatDate type="date"
value="${now}" /></p>
<p>Formatted Date (3): <fmt:formatDate type="both"
value="${now}" /></p>
<p>Formatted Date (4): <fmt:formatDate type="both"
dateStyle="short" timeStyle="short"
value="${now}" /></p>
<p>Formatted Date (5): <fmt:formatDate type="both"
dateStyle="medium" timeStyle="medium"
value="${now}" /></p>
<p>Formatted Date (6): <fmt:formatDate type="both"
dateStyle="long" timeStyle="long"
value="${now}" /></p>
<p>Formatted Date (7): <fmt:formatDate pattern="yyyy-MM-dd"
value="${now}" /></p> </body>
</html>

这将产生以下结果:

Date Format:

Formatted Date (1): 14:27:18

Formatted Date (2): 23-Sep-2010

Formatted Date (3): 23-Sep-2010 14:27:18

Formatted Date (4): 23/09/10 14:27

Formatted Date (5): 23-Sep-2010 14:27:18

Formatted Date (6): 23 September 2010 14:27:18 GST

Formatted Date (7): 2010-09-23

jstl <fmt:formatDate>标签的更多相关文章

  1. jstl <fmt:formatNumber>标签

    标签用于格式化数字,百分比和货币. 如果type属性为百分比或数字,则可以使用多个数字格式属性.maxIntegerDigits和minIntegerDigits属性允许您指定数字的非分数部分的大小. ...

  2. jstl的formatNumber标签的四舍五入问题

    jstl的formatNumber标签的四舍五入问题 近日使用JSTL的formatNumber 标签进行四舍五入时,发现它竟然使用的是"4舍6入5奇偶"的算法. 要实现" ...

  3. <fmt:formatNumber>标签

    <fmt:formatNumber>标签用于格式化数字,百分比,货币. 属性 <fmt:formatNumber>标签有如下属性: 属性 描述 是否必要 默认值 value 要 ...

  4. JSTL fmt:formatNumber 数字、货币格式化

    <fmt:formatNumber value="12.34" pattern="#0.00" /> 12.34 保留小数点后两位数 <fmt ...

  5. JSTL——formatNumber标签

    使用场合: <fmt:formatNumber>标签用于格式化数字,百分比,货币 属性: 语法 如果使用pattern属性.这个属性可以让您在对数字编码时包含指定的字符.接下来的表格中列出 ...

  6. (2)JSTL的fmt国际化标签库

    format标签库:做国际化格式化,分两类 : 国际化核心标签:<fmt:setLocale>.<fmt:bundle>.<fmt:setBundle>.<f ...

  7. JSTL 数字日期标签库

    <frm:formatNumber/>标签 该标签依据特定的区域将数字改变为不同的格式来显示. 被格式化的数据<frm:formatNumber> <fmt:format ...

  8. jstl fmt标签的使用

    所有标签 fmt:requestEncoding fmt:setLocale fmt:timeZone fmt:setTimeZone fmt:bundle fmt:setBundle fmt:mes ...

  9. fmt:formatNumber use locale display negative currency in -$xxx.xx format in JSTL

    First, we want to know our own locale,how to display the locale in a JSTL? <c:out value="${p ...

随机推荐

  1. hdu 1172 猜数字

    猜数字 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  2. hdu 2616 Kill the monster (DFS)

    Kill the monster Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  3. 幸运数字(luckly)

    幸运数字(luckly) 题目描述 A国共有 nn 座城市,这些城市由 TeX parse error: Misplaced & 条道路相连,使得任意两座城市可以互达,且路径唯一.每座城市都有 ...

  4. bzoj1264 [AHOI2006]基因匹配Match 树状数组+lcs

    1264: [AHOI2006]基因匹配Match Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1255  Solved: 835[Submit][ ...

  5. MySQL基本管理和应用

    # yum install mysql-server # /etc/init.d/mysqld startInitializing MySQL database: Installing MySQL s ...

  6. SJCL:斯坦福大学JS加密库

    斯坦福大学Javascript加密库简称SJCL,是一个由斯坦福大学计算机安全实验室创立的项目,旨在创建一个安全.快速.短小精悍.易使用.跨浏览器的JavaScript加密库.(斯坦福大学下载地址:h ...

  7. ZOJ 3822 Domination (三维概率DP)

    E - Domination Time Limit:8000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu Submi ...

  8. 【IDEA】使用intellij的idea集成开发工具中的git插件

    注意:这里并没有介绍git客户端的安装,如果要安装客户端,大家可以参考如下的链接: http://www.runoob.com/git/git-install-setup.html 1.在使用这个id ...

  9. oracle 的数组(转)

    declare type t_indexby is table of number index by binary_integer; type t_nested is table of number; ...

  10. Linux下Redis使用

    1. 简介 REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统. 2. 安装 安装方法如下: # yum i ...