| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1576 人关注过本帖
标题:[分享]分享DateFormat类(参考java)
只看楼主 加入收藏
野蛮女人
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:827
专家分:0
注 册:2007-4-7
结帖率:100%
收藏
 问题点数:0 回复次数:1 
[分享]分享DateFormat类(参考java)

js文件在:a9engine/com/trydofor/a9js/format/date.js
测试页面在:a9engine/__testdemo__/com_trydofor_a9js_format/test-date_format.htm
下面是使用方法:

/**
UTF8(BOM) GPL trydofor.com May.2007
===========================================================
DateFormatClass
like the java's SimpleDateFormat.

Letter Date or Time Component Presentation Examples UserDic
y Year Year 1996; 96
M Month in year Month July; Jul; 07 *
d Day in month Number 10
E Day in week Text Tuesday; Tue; 2 *
a Am/pm marker Text pm,p *
H Hour in day (0-23) Number 0
h Hour in am/pm (1-12) Number 12
m Minute in hour Number 30
s Second in minute Number 55
S Millisecond Number 978

Date and Time Pattern Result
"yyyy.MM.dd 'at' HH:mm:ss" 2001.07.04 at 12:08:56
"EEE, MMM d, ''yy" Wed, Jul 4, '01
"h:mm a" 12:08 p
"hh 'o''clock' aa" 12 o'clock pm
"yyyyy.MMMMM.dd hh:mm aaa" 2001.July.04 12:08 pm
"EEE, d MMM yyyy HH:mm:ss" Wed, 4 Jul 2001 12:08:56
"yyMMddHHmmss" 010704120856
"'''ad'''yyyy'year'MM'month'dd''" 'ad'2007year06month16'
"MM'yyyy''yyyy'yyyy" 06yyyy'yyyy2007


String format(formatStr,date,userDic)
将日期格式化成设定的格式.
formatStr: 格式化字符串(参考上面说明)
date: 需要格式化的日期,为空时,使用当前时间
userDic: 替换默认的显示(ampm,month,week)
格式:
userDic = {M:[[简称,全程],],E:[[简称,全称],],a:[[简称,全称],]}
userDic = {
M:[
['Sun','Sunday'],
['Mon','Monday'],
['Tue','Tuesday'],
['Wed','Wednesday'],
['Thu','Thursday'],
['Fri','Friday'],
['Sat','Saturday']
],
E:[
['Jan','January'],
['Feb','Feburary'],
['Mar','March'],
['Apr','April'],
['May','May'],
['Jun','June'],
['Jul','July'],
['Aug','August'],
['Sep','September'],
['Oct','October'],
['Nov','November'],
['Dec','December']
],
a:[['a','am'],['p','pm']]
}

*/

搜索更多相关主题的帖子: java DateFormat format trydofor GPL 
2007-09-05 18:39
花花公子
Rank: 4
等 级:贵宾
威 望:10
帖 子:609
专家分:0
注 册:2007-6-7
收藏
得分:0 
看不懂

[glow=150,blue,2] 该珍惜的,好好把握;该舍去的,不再留恋; 该执著的,永不怨悔;该面对的,绝不逃避。[/glow]
2007-09-06 16:27
快速回复:[分享]分享DateFormat类(参考java)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030571 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved