jstl <fmt:formatDate>标签
<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>标签的更多相关文章
- jstl <fmt:formatNumber>标签
标签用于格式化数字,百分比和货币. 如果type属性为百分比或数字,则可以使用多个数字格式属性.maxIntegerDigits和minIntegerDigits属性允许您指定数字的非分数部分的大小. ...
- jstl的formatNumber标签的四舍五入问题
jstl的formatNumber标签的四舍五入问题 近日使用JSTL的formatNumber 标签进行四舍五入时,发现它竟然使用的是"4舍6入5奇偶"的算法. 要实现" ...
- <fmt:formatNumber>标签
<fmt:formatNumber>标签用于格式化数字,百分比,货币. 属性 <fmt:formatNumber>标签有如下属性: 属性 描述 是否必要 默认值 value 要 ...
- JSTL fmt:formatNumber 数字、货币格式化
<fmt:formatNumber value="12.34" pattern="#0.00" /> 12.34 保留小数点后两位数 <fmt ...
- JSTL——formatNumber标签
使用场合: <fmt:formatNumber>标签用于格式化数字,百分比,货币 属性: 语法 如果使用pattern属性.这个属性可以让您在对数字编码时包含指定的字符.接下来的表格中列出 ...
- (2)JSTL的fmt国际化标签库
format标签库:做国际化格式化,分两类 : 国际化核心标签:<fmt:setLocale>.<fmt:bundle>.<fmt:setBundle>.<f ...
- JSTL 数字日期标签库
<frm:formatNumber/>标签 该标签依据特定的区域将数字改变为不同的格式来显示. 被格式化的数据<frm:formatNumber> <fmt:format ...
- jstl fmt标签的使用
所有标签 fmt:requestEncoding fmt:setLocale fmt:timeZone fmt:setTimeZone fmt:bundle fmt:setBundle fmt:mes ...
- 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 ...
随机推荐
- hdu 1242 Rescue (BFS)
Rescue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- hdu 2899 Strange fuction (二分法)
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 如何写出高质量的JavaScript代码
优秀的Stoyan Stefanov在他的新书中(<Javascript Patterns>)介绍了很多编写高质量代码的技巧,比如避免使用全局变量,使用单一的var关键字,循环式预存长度等 ...
- 平面ray trace的数据结构加速
yy了一个数据结构.. 首先考虑到,平面ray trace对应的scene是planar graph with coordinates,特点是除端点外无相交. 我们考虑对所有端点建立kd-tree,注 ...
- 信号槽库:sigslot.h和sigc++使用
用qt的知道,qt有方便简单的信号槽机制,但需要专门的qt工具处理. 如果想直接使信号槽就可以使用sigslot库,或者sigc++库,或者boost中的signals,这里介绍sigslot和sig ...
- HTML添加上传图片并进行预览
使用说明:新建文件,直接复制粘贴,保存文件为html 格式,在浏览器运行即可: 第一种: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Tr ...
- UVALive 6451:Tables(模拟 Grade D)
VJ题目链接 题意:模拟输出表格 思路:模拟……很暴力 代码: #include <cstdio> #include <cstring> #include <cstdli ...
- 测试 System.SysUtils.TStringHelper
来自:http://www.cnblogs.com/del/archive/2013/06/14/3135002.html -------------------------------------- ...
- C3P0连接池工具类使用
c3p0的基本连接配置文件 c3p0-config.xml <c3p0-config> <default-config> <property name="dri ...
- python的递归算法学习(3):汉诺塔递归算法
汉诺塔问题是递归函数的经典应用,它来自一个古老传说:在世界刚被创建的时候有一座钻石宝塔A,其上有64个金蝶.所有碟子按从大到小的次序从塔底堆放至塔顶.紧挨着这座塔有另外两个钻石宝塔B和C.从世界创始之 ...