<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. Python空间数据处理环境搭

    Python空间数据处理环境搭 Conda的下载和安装 什么是Conda? 官方定义:Package, dependency and environment management for any la ...

  2. 实时流处理Storm、Spark Streaming、Samza、Flink孰优孰劣

    对于一个成熟的消息中间件而言,消息格式不仅关系到功能维度的扩展,还牵涉到性能维度的优化.随着Kafka的迅猛发展,其消息格式也在不断的升级改进,从0.8.x版本开始到现在的1.1.x版本,Kafka的 ...

  3. POJ 1064 Cable master | 二分+精度

    题目: 给n个长度为l[i](浮点数)的绳子,要分成k份相同长度的 问最多多长 题解: 二分长度,控制循环次数来控制精度,输出也要控制精度<wa了好多次> #include<cstd ...

  4. php中json_encode和json_decode的用法

    1.json_encode基本用法:数组转字符串 <?php $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5); ...

  5. ACM-The Coco-Cola Store

    题目: Once upon a time, there is a special coco-cola store. If you return three empty bottles to the s ...

  6. 扩展欧几里得(ex_gcd),中国剩余定理(CRT)讲解 有代码

    扩展欧几里得算法 求逆元就不说了. ax+by=c 这个怎么求,很好推. 设d=gcd(a,b) 满足d|c方程有解,否则无解. 扩展欧几里得求出来的解是 x是 ax+by=gcd(a,b)的解. 对 ...

  7. 51Nod 1601 完全图的最小生成树计数

    题目链接 分析: 这是一张完全图,并且边的权值是由点的权值$xor$得到的,所以我们考虑贪心的思想,考虑$kruskal$的过程选取最小的边把两个连通块合并,所以我们可以模仿$kruskal$的过程, ...

  8. POJ1200 Crazy Search

    Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Description Many peo ...

  9. Unicode与UTF-8互转(C语言实现) 基本原理

    1. 基础 1.1 ASCII码 我们知道, 在计算机内部, 所有的信息最终都表示为一个二进制的字符串. 每一个二进制位(bit)有0和1两种状态, 因此八个二进制位就可以组合出 256种状态, 这被 ...

  10. 使用 Python 开始你的机器学习之旅【转】

    转自:https://linux.cn/article-8582-1.html 编译自:https://opensource.com/article/17/5/python-machine-learn ...