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 ...
随机推荐
- VMware ESXI 5.5 注册码
VMware ESXI 5.5 注册码 ESXI 注册码0A42V-8M182-3ZZ88-R21N6-32K5H ESXi Server许可证类型产品: Mware vSphere 5 Enterp ...
- Angular1 基础知识 浅析(含锚点)
1.angular:前端js框架 https://angularjs.org ① SPA单页应用程序 通过ajax从后台获取数据,动态渲染页面,不出现白屏,提高效率,节省流量 (1)锚点值 锚点:是 ...
- (转)巴氏(bash)威佐夫(Wythoff)尼姆(Nim)博弈之模板
感谢:巴氏(bash)威佐夫(Wythoff)尼姆(Nim)博弈之模板 转自:http://colorfulshark.cn/wordpress/巴氏(bash)威佐夫(wythoff)尼姆(nim) ...
- Mysql性能优化【转】
mysql的性能优化无法一蹴而就,必须一步一步慢慢来,从各个方面进行优化,最终性能就会有大的提升. Mysql数据库的优化技术 对mysql优化是一个综合性的技术,主要包括 表的设计合理化(符合3NF ...
- python enumerate元素的时候可以获取下标,并且可以指定开始的下标值。
list=["a","b","c","d","e"] for i,item in enumerate ...
- 链表各种操作及其实现方法(c实现)
链表是一种最简单的数据结构之一,经常会被面试官用来考察应聘者的基础扎不扎实,最近也到了求职季,所以我把自己对链表的一些理解写出来,希望能跟大家交流交流: 链表的概念其实挺简单,无非就是一个利用指针将数 ...
- python的递归算法学习(2):具体实现:斐波那契和其中的陷阱
1.斐波那契 什么是斐波那契,斐波那契额就是一个序列的整数的排序,其定义如下: Fn = Fn-1 + Fn-2 with F0 = 0 and F1 = 1 也就是,0,1,1,2,3,5,8,13 ...
- Postman前端HTTP请求调试神器教程
Postman功能: 主要用于模拟网络请求包 快速创建请求 回放.管理请求 快速设置网络代理 我们看下界面: 一 接口请求流程: 二 postman使用 从流程图中我们可以看出,一个接口请求需要设 ...
- 纠正网上乱传的android调用Webservice方法。
1.写作背景: 笔者想实现android调用webservice,可是网上全是不管对与错乱转载的文章,结果不但不能解决问题,只会让人心烦,所以笔者决定将自己整理好的能用的android调用webser ...
- Git 使用指南(cmd + gui)
git 使用简易指南http://www.bootcss.com/p/git-guide/ Git版本控制使用方法入门教程http://www.uml.org.cn/pzgl/201204285.as ...