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 ...
随机推荐
- Dev express 笔记
1.设置treelist不同行的颜色 void treeList1_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDr ...
- LeetCode -- Implement Stacks using Queue
Question: Implement the following operations of a queue using stacks. push(x) -- Push element x to t ...
- HDU1263 map二维运用
#include <iostream> #include <cstdio> #include <cstring> #include <map> #inc ...
- 结构型设计模式之适配器模式(Adapter)
结构 意图 将一个类的接口转换成客户希望的另外一个接口.A d a p t e r 模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作. 适用性 你想使用一个已经存在的类,而它的接口不符合你 ...
- 【排序算法】java实现
1.冒泡排序 最简单的排序实现,冒泡排序,是一种交换排序,它的基本思想是:两两比较相邻记录的关键字,如果反序则交换,直到没有反序的记录为止. //冒泡排序 private int[] bubbleSo ...
- C语言中字符串的格式化
本文整理转载自:http://wenku.baidu.com/view/065d62fff705cc1755270989.html C语言中格式字符串的一般形式为: %[标志][输出最小宽度][.精度 ...
- MyBatis学习总结(一)mybatis与spring整合
MyBatis学习总结(一)mybatis与spring整合 一.需要的jar包 1.spring相关jar包 2.Mybatis相关的jar包 3.Spring+mybatis相关jar包 4.My ...
- Mysql 连接池
数据库连接池的作用: 数据库连接池负责分配.管理和释放数据库连接,它允许应用程序重复使用一个现有的数据库连接,而不是再重新建立一个:释放空闲时间超过最大空闲时间的数据库连接来避免因为没有释放数据库连接 ...
- [译]java8新特性:函数式编程(functional programming)的优点
Java8引入了函数式编程,他对java是一个极大的扩展.Java从此不在是一个单纯的面向对象语言,现在他同时混合了函数式编程.这是巨大的改变,需要我们调整面对对象的编程习惯,以适应这些变化. 但是为 ...
- 第二部分:Spring中配置mongodb
一.需要引用的jar包 1.spring-data-mongodb-1.9.4.RELEASE.jar 2.spring-data-commons-1.12.11.RELEASE.jar 3.mong ...