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 ...
随机推荐
- 【bzoj2879】[Noi2012]美食节 费用流+动态加边
原文地址:http://www.cnblogs.com/GXZlegend 题目描述 CZ市为了欢迎全国各地的同学,特地举办了一场盛大的美食节.作为一个喜欢尝鲜的美食客,小M自然不愿意错过这场盛宴.他 ...
- 【Luogu】P3228数列(数学题)
题目链接 考虑我们把所有的增加量拿出来做成一个序列b. 那么在所有n中开头中$1~\sum\limits_{i=1}^{k-1}b[i]$是合法的 也就是说我们枚举所有b[i],然后答案就是$n*m^ ...
- 【BZOJ1179】[Apio2009]Atm (tarjan+SPFA)
显而易见的tarjan+spfa...不解释了 ; type edgetype=record toward,next:longint; end; var edge1,edge2:..maxn] of ...
- linux进程——后台运行的方法
linux进程后台运行的几种方法: 我们经常会碰到这样的问题,用 telnet/ssh 登录了远程的 Linux 服务器,运行了一些耗时较长的任务, 结果却由于网络的不稳定导致任务中途失败. 如何让命 ...
- Oracle 11g R2 64位在 win7 64位的安装流程图解
1.下载安装包,可以到oracle官方网站.也可以在这里下载: http://pan.baidu.com/s/1X9xDk 2.解压2个安装包,到同一个database目录: 3.点击database ...
- java.net.BindException: Address already in use: JVM_Bind <null>:8080错误
今天打开myeclipse出现java.net.BindException: Address already in use: JVM_Bind <null>:8080错误 从网上搜了一下大 ...
- Redis为什么单进程单线程也那么快
[转] http://www.syyong.com/db/Redis-why-the-use-of-single-process-and-single-threaded-way-so-fast.htm ...
- 【CF1016F】Road Projects(贪心)
题意:给你一棵n 个节点的树,定义1到n的代价是1到 n节点间的最短路径的长度. 现在给你 m 组询问,让你添加一条边权为 w 的边(不与原图重复),求代价的最大值.询问之间相互独立. 1≤n,m≤3 ...
- Vim 自动补全成对的括号和引号
修改后: 1 :inoremap (()<ESC>i 2:inoremap )<c-r>=ClosePair(')')<CR> 3:inoremap {{}< ...
- Android 系统启动过程详解
android 使用 linux 内核,一般运行在 ARM 体系架构上,android 设备启动的过程,应用层之下基本等同于linux, 从应用层第一个程序init开始有所区别,下面开始介绍. ste ...