fmt标签的格式化日期使用





<div class="article_title"><span class="ico ico_type_Repost"></span><br>
</div>
<div class="article_manage"><span class="link_categories">分类: <a target="_blank" href="http://blog.csdn.net/vbubble/article/category/937338">
jsp</a> </span><span class="link_postdate">2011-12-13 17:43</span> <span class="link_view" title="阅读次数">
315人阅读</span> <span class="link_comments" title="评论次数"><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#comments">评论</a>(0)</span>
<span class="link_collect"><a target="_blank" title="收藏">收藏</a></span> <span class="link_report">
<a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#report" title="举报">举报</a></span>
</div>
<p><strong><span style="color:#cc0000">声明:</span></strong></p>
<div class="dp-highlighter bg_html">
<div class="bar">
<div class="tools"><strong>[html]</strong> <a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="ViewSource" title="view plain">
view plain</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="CopyToClipboard" title="copy">copy</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="PrintSource" title="print">print</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="About" title="?">?</a><div style="position: absolute; left: 429px; top: 407px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" name="ZeroClipboardMovie_1" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&amp;width=18&amp;height=18" wmode="transparent" align="middle" height="18" width="18"></div></div>
</div>
<ol class="dp-xml" start="1">
<li class="alt"><span><span class="tag">&lt;</span><span>%@&nbsp;taglib&nbsp;</span><span class="attribute">prefix</span><span>=</span><span class="attribute-value">"fmt"</span><span>&nbsp;</span><span class="attribute">uri</span><span>=</span><span class="attribute-value">"/WEB-INF/fmt.tld"</span><span>&nbsp;%</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;&nbsp;</span></span></li></ol>
<div style="display: none;" class="save_code tracking-ad" data-mod="popu_249"><a target="_blank" href="javascript:;"><img src="http://static.blog.csdn.net/images/save_snippets_01.png"></a></div></div>
<div class="dp-highlighter bg_html">
<div class="bar">
<div class="tools"><strong>[html]</strong> <a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="ViewSource" title="view plain">
view plain</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="CopyToClipboard" title="copy">copy</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="PrintSource" title="print">print</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="About" title="?">?</a><div style="position: absolute; left: 429px; top: 476px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" name="ZeroClipboardMovie_2" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&amp;width=18&amp;height=18" wmode="transparent" align="middle" height="18" width="18"></div></div>
</div>
<ol class="dp-xml" start="1">
<li class="alt"><span><span>or&nbsp;&nbsp;&nbsp;</span></span></li></ol>
<div style="display: none;" class="save_code tracking-ad" data-mod="popu_249"><a target="_blank" href="javascript:;"><img src="http://static.blog.csdn.net/images/save_snippets_01.png"></a></div></div>
<div class="dp-highlighter bg_html">
<div class="bar">
<div class="tools"><strong>[html]</strong> <a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="ViewSource" title="view plain">
view plain</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="CopyToClipboard" title="copy">copy</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="PrintSource" title="print">print</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="About" title="?">?</a><div style="position: absolute; left: 429px; top: 545px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" name="ZeroClipboardMovie_3" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&amp;width=18&amp;height=18" wmode="transparent" align="middle" height="18" width="18"></div></div>
</div>
<ol class="dp-xml" start="1">
<li class="alt"><span><span class="tag">&lt;</span><span>%@&nbsp;taglib&nbsp;</span><span class="attribute">prefix</span><span>=</span><span class="attribute-value">"fmt"</span><span>&nbsp;</span><span class="attribute">uri</span><span>=</span><span class="attribute-value">"http://java.sun.com/jsp/jstl/fmt"</span><span>&nbsp;%</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li></ol>
<div style="display: none;" class="save_code tracking-ad" data-mod="popu_249"><a target="_blank" href="javascript:;"><img src="http://static.blog.csdn.net/images/save_snippets_01.png"></a></div></div>
<br>
<strong><span style="color:#ff0000">语法:</span></strong>
<div class="dp-highlighter bg_html">
<div class="bar">
<div class="tools"><strong>[html]</strong> <a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="ViewSource" title="view plain">
view plain</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="CopyToClipboard" title="copy">copy</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="PrintSource" title="print">print</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="About" title="?">?</a><div style="position: absolute; left: 429px; top: 684px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_4" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" name="ZeroClipboardMovie_4" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=4&amp;width=18&amp;height=18" wmode="transparent" align="middle" height="18" width="18"></div></div>
</div>
<ol class="dp-xml" start="1">
<li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"转换对象"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"转换格式"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li></ol>
<div style="display: none;" class="save_code tracking-ad" data-mod="popu_249"><a target="_blank" href="javascript:;"><img src="http://static.blog.csdn.net/images/save_snippets_01.png"></a></div></div>
<br>
<strong><span style="color:#990000">属性详解:</span></strong>
<p><strong><span style="color:#990000"><br>
</span></strong></p>
<p>1)date:是要格式化的日期<br>
<br>
<br>
2)value::要格式化的值,这里就是date<br>
<br>
<br>
3)type::格式化的样式<br>
<br>
<br>
4)dateStyle:具体样式(比type更具体的描述,可以不写,请对比2,4,5,6,7,8)<br>
</p>
<p><br>
</p>
<p><strong><span style="color:#ff0000">使用:</span></strong></p>
<div class="dp-highlighter bg_html">
<div class="bar">
<div class="tools"><strong>[html]</strong> <a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="ViewSource" title="view plain">
view plain</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="CopyToClipboard" title="copy">copy</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="PrintSource" title="print">print</a><a target="_blank" href="http://blog.csdn.net/vbubble/article/details/7067741#" class="About" title="?">?</a><div style="position: absolute; left: 429px; top: 1161px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_5" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" name="ZeroClipboardMovie_5" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=5&amp;width=18&amp;height=18" wmode="transparent" align="middle" height="18" width="18"></div></div>
</div>
<ol class="dp-xml" start="1">
<li class="alt"><span><span>1.</span><span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"both"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li><span>输出格式:&nbsp;2010-5-31&nbsp;23:59:59&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;</span></li><li class="alt"><span>2.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"date"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li><span>输出格式:&nbsp;2010-4-1&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li><span>3.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"time"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>输出格式:&nbsp;23:59:59&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;</span></li><li class="alt"><span>4.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"date"</span><span>&nbsp;</span><span class="attribute">dateStyle</span><span>=</span><span class="attribute-value">"default"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li><span>输出格式:2010-5-31&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li><span>5.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"date"</span><span>&nbsp;</span><span class="attribute">dateStyle</span><span>=</span><span class="attribute-value">"short"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>输出格式:04-5-31&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;</span></li><li class="alt"><span>6.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"date"</span><span>&nbsp;</span><span class="attribute">dateStyle</span><span>=</span><span class="attribute-value">"medium"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li><span>输出格式:2010-5-31&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li><span>7.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"date"</span><span>&nbsp;</span><span class="attribute">dateStyle</span><span>=</span><span class="attribute-value">"long"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>输出格式:&nbsp;2010年5月31日&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;</span></li><li class="alt"><span>8.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"date"</span><span>&nbsp;</span><span class="attribute">dateStyle</span><span>=</span><span class="attribute-value">"full"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li><span>输出格式:2010年5月31日&nbsp;星期一&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li><span>9.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"time"</span><span>&nbsp;</span><span class="attribute">timeStyle</span><span>=</span><span class="attribute-value">"default"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>输出格式:&nbsp;23:59:59&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;</span></li><li class="alt"><span>10.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"time"</span><span>&nbsp;</span><span class="attribute">timeStyle</span><span>=</span><span class="attribute-value">"short"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li><span>输出格式:下午11:59&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li><span>11.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"time"</span><span>&nbsp;</span><span class="attribute">timeStyle</span><span>=</span><span class="attribute-value">"medium"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>输出格式:&nbsp;23:59:59&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;</span></li><li class="alt"><span>12.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"time"</span><span>&nbsp;</span><span class="attribute">timeStyle</span><span>=</span><span class="attribute-value">"long"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li><span>输出格式:&nbsp;下午11时59分59秒&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li><span>13.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"time"</span><span>&nbsp;</span><span class="attribute">timeStyle</span><span>=</span><span class="attribute-value">"full"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>输出格式:&nbsp;下午11时59分59秒&nbsp;CDT&nbsp;&nbsp;</span></li><li><span>&nbsp;&nbsp;</span></li><li class="alt"><span>14.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"both"</span><span>&nbsp;</span><span class="attribute">pattern</span><span>=</span><span class="attribute-value">"EEEE,&nbsp;MMMM&nbsp;d,&nbsp;yyyy&nbsp;输出格式:&nbsp;HH:mm:ss&nbsp;Z"</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li><span>星期四,&nbsp;四月&nbsp;1,&nbsp;2010&nbsp;13:30:00&nbsp;-0600&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;&nbsp;</span></li><li><span>15.<span class="tag">&lt;</span><span class="tag-name">fmt:formatDate</span><span>&nbsp;</span><span class="attribute">value</span><span>=</span><span class="attribute-value">"${date}"</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">"both"</span><span>&nbsp;</span><span class="attribute">pattern</span><span>="d&nbsp;MMM&nbsp;yy,&nbsp;h:m:s&nbsp;a&nbsp;zzzz</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>输出格式:&nbsp;31&nbsp;五月&nbsp;04,&nbsp;11:59:59&nbsp;下午&nbsp;中央夏令时&nbsp;&nbsp;&nbsp; <br>
</span></li></ol>
<div class="save_code tracking-ad" data-mod="popu_249"><a target="_blank" href="javascript:;"><img src="http://static.blog.csdn.net/images/save_snippets.png"></a></div></div>
<br>
   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值