fmt:formatDate标签的输出格式

<fmt:formatDate>标签的输出格式:
  d   月中的某一天。一位数的日期没有前导零。   
  dd   月中的某一天。一位数的日期有一个前导零。   
  ddd   周中某天的缩写名称,在   AbbreviatedDayNames   中定义。   
  dddd   周中某天的完整名称,在   DayNames   中定义。   
  M   月份数字。一位数的月份没有前导零。   
  MM   月份数字。一位数的月份有一个前导零。   
  MMM   月份的缩写名称,在   AbbreviatedMonthNames   中定义。   
  MMMM   月份的完整名称,在   MonthNames   中定义。   
  y   不包含纪元的年份。如果不包含纪元的年份小于   10,则显示不具有前导零的年份。   
  yy   不包含纪元的年份。如果不包含纪元的年份小于   10,则显示具有前导零的年份。   
  yyyy   包括纪元的四位数的年份。   
  gg   时期或纪元。如果要设置格式的日期不具有关联的时期或纪元字符串,则忽略该模式。   
 
h   12   小时制的小时。一位数的小时数没有前导零。从1到12,分上下午 范围:01:00 AM~12:59AM    
  hh   12   小时制的小时。一位数的小时数有前导零。   
  H   24   小时制的小时。一位数的小时数没有前导零。从0到23,范围:00:00 AM~23:59AM    
  HH   24   小时制的小时。一位数的小时数有前导零。   
  m   分钟。一位数的分钟数没有前导零。   
  mm   分钟。一位数的分钟数有一个前导零。   
  s   秒。一位数的秒数没有前导零。   
  ss   秒。一位数的秒数有一个前导零。

  

示例:index.jsp 

 

    {type:both}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="both"/><!-- 2011-3-30 9:41:21 -->
    <br/>
    {type:date}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="date"/><!-- 2011-3-30 -->
    <br/>
    {type:time}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="time"/><!-- 9:44:44 -->
    <br/>
    {type:date, dateStyle:default}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="date" dateStyle="default"/><!-- 2011-3-30 -->
    <br/>
    {type:date, dateStyle:short}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="date" dateStyle="short"/><!-- 11-3-30  -->
    <br/>
    {type:date, dateStyle:medium}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="date" dateStyle="medium"/><!-- 2011-3-30 -->
    <br/>
    {type:date, dateStyle:long}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="date" dateStyle="long"/><!-- 2011年3月30日 -->
    <br/>
    {type:date, dateStyle:full}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="date" dateStyle="full"/><!-- 2011年3月30日 星期三 -->
     <br/>
    {type:time, timeStyle:default}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="time" timeStyle="default"/><!-- 10:01:32  -->
    <br/>
    {type:time, timeStyle:short}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="time" timeStyle="short"/><!-- 上午10:01  -->
    <br/>
    {type:time, timeStyle:medium}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="time" timeStyle="medium"/><!-- 10:01:32 -->
    <br/>
    {type:time, timeStyle:long}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="time" timeStyle="long"/><!-- 上午10时01分32秒 -->
    <br/>
    {type:time, timeStyle:full}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="time" timeStyle="full"/><!-- 上午10时01分32秒 CST  -->
    <br/>
    {type:both, pattern:EEEE, MMMM d, yyyy HH:mm:ss Z}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="both" pattern="EEEE, MMMM d, yyyy HH:mm:ss Z"/><!-- 星期三, 三月 30, 2011 10:01:32 +0800  -->
    <br/>
    {type:both, pattern:d MMM yy, h:m:s a zzzz}&nbsp;&nbsp;<fmt:formatDate value="<%=new Date() %>" type="both" pattern="d MMM yy, h:m:s a zzzz"/><!-- 30 三月 11, 10:1:32 上午 中国标准时间 -->
    <br/>
    {pattern:dd/MM/yyyy HH:mm aa}}&nbsp;&nbsp;<fmt:formatDate value="<%=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2011-3-30 13:12:12") %>" pattern="dd/MM/yyyy HH:mm aa"/><!-- 30/03/2011 13:12 下午 -->
    <br/>
    {pattern:dd/MM/yyyy hh:mm aa}&nbsp;&nbsp;<fmt:formatDate value="<%=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2011-3-30 13:12:12") %>" pattern="dd/MM/yyyy hh:mm aa"/><!-- 30/03/2011 01:12 下午 -->

 

 

 

  

 

显示结果:

 

{type:both}  2011-3-30 10:07:42
{type:date}  2011-3-30
{type:time}  10:07:42
{type:date, dateStyle:default}  2011-3-30
{type:date, dateStyle:short}  11-3-30
{type:date, dateStyle:medium}  2011-3-30
{type:date, dateStyle:long}  2011年3月30日
{type:date, dateStyle:full}  2011年3月30日 星期三
{type:time, timeStyle:default}  10:07:42
{type:time, timeStyle:short}  上午10:07
{type:time, timeStyle:medium}  10:07:42
{type:time, timeStyle:long}  上午10时07分42秒
{type:time, timeStyle:full}  上午10时07分42秒 CST
{type:both, pattern:EEEE, MMMM d, yyyy HH:mm:ss Z}  星期三, 三月 30, 2011 10:07:42 +0800
{type:both, pattern:d MMM yy, h:m:s a zzzz}  30 三月 11, 10:7:42 上午 中国标准时间
{pattern:dd/MM/yyyy HH:mm aa}  30/03/2011 13:12 下午
{pattern:dd/MM/yyyy hh:mm aa}  30/03/2011 01:12 下午

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值