空间站

北极心空

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  15 Posts :: 393 Stories :: 160 Comments :: 0 Trackbacks
 1 JSP Standard Tag Libraries   
 2 Formatting and Internationalization   
 3 Two form input parameters, 'date' and 'isoDate', are URL-encoded in the link leading to this page. 'isoDate' is formatted according to the ISO8601 standard.   
 4 Formatting of numbers and dates is based on the browser's locale setting. Formatting will change if you switch the default language setting from English to French or German, for example. (The browser needs to be restarted, too.)   
 5   
 6 Library import and parameter capturing:   
 7   
 8 <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>  
 9 <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>  
10   
11 <fmt:parseDate value="${param.date}" var="date" pattern="yyyy/MM/dd:HH:mm:ss>  
12 <fmt:parseDate value="${param.isoDate}" var="isoDate" pattern="yyyyMMdd'T'HHmmss">  
13   
14 The input parameters must match the patterns, or the JSP will thrown an exception. This page does no error handling.   
15   
16 Input parameters:   
17 Date:    2004/04/01:13:30:00   Java format: Thu Apr 01 13:30:00 CST 2004   
18 isoDate: 20040531T235959       Java format: Mon May 31 23:59:59 CDT 2004   
19   
20 Dates   
21 Tag Output   
22 Attribute: value; required. Tag has no body.   
23 <fmt:formatDate value="${date}" type="both"/>  
24   
25  2004-4-1 13:30:00     
26 <fmt:formatDate value="${isoDate}" type="both"/>  
27   
28  2004-5-31 23:59:59     
29 Attribute: type; optional. Indicates what to print: date, time, or both.   
30 <fmt:formatDate value="${date}" type="date"/>  
31   
32  2004-4-1     
33 <fmt:formatDate value="${isoDate}" type="time"/>  
34   
35  23:59:59     
36 Attribute: dateStyle; optional. Varies the date format.   
37 <fmt:formatDate value="${isoDate}" type="date" dateStyle="default"/>  
38   
39  2004-5-31     
40 <fmt:formatDate value="${isoDate}" type="date" dateStyle="short"/>  
41   
42  04-5-31     
43 <fmt:formatDate value="${isoDate}" type="date" dateStyle="medium"/>  
44   
45  2004-5-31     
46 <fmt:formatDate value="${isoDate}" type="date" dateStyle="long"/>  
47   
48  2004年5月31日     
49 <fmt:formatDate value="${isoDate}" type="date" dateStyle="full"/>  
50   
51  2004年5月31日 星期一     
52 Attribute: timeStyle; optional. Varies the time format.   
53 <fmt:formatDate value="${isoDate}" type="time" timeStyle="default"/>  
54   
55  23:59:59     
56 <fmt:formatDate value="${isoDate}" type="time" timeStyle="short"/>  
57   
58  下午11:59     
59 <fmt:formatDate value="${isoDate}" type="time" timeStyle="medium"/>  
60   
61  23:59:59     
62 <fmt:formatDate value="${isoDate}" type="time" timeStyle="long"/>  
63   
64  下午11时59分59秒     
65 <fmt:formatDate value="${isoDate}" type="time" timeStyle="full"/>  
66   
67  下午11时59分59秒 CDT     
68 Attribute: pattern; optional. Inidcates date/time custom patterns.   
69 <fmt:formatDate value="${date}" type="both" pattern="EEEE, MMMM d, yyyy HH:mm:ss Z"/>  
70   
71  星期四, 四月 1, 2004 13:30:00 -0600     
72 <fmt:formatDate value="${isoDate}" type="both" pattern="d MMM yy, h:m:s a zzzz/>  
73   
74  31 五月 04, 11:59:59 下午 中央夏令时  
75 
posted on 2008-08-12 15:50 芦苇 阅读(806) 评论(0)  编辑  收藏 所属分类: JAVAHTML & Script

只有注册用户登录后才能发表评论。


网站导航: