首页 > 分享 > Flex中日期的转换

Flex中日期的转换

最新推荐文章于 2015-08-25 14:50:13 发布

czx33859066 于 2008-11-26 10:24:00 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

在Flex中如何格式化日期在Flex的应用中,我们有时候需要格式化一下日期的格式,该如何做呢

import mx.formatters.*;private var myDataate=new Date(); private function changeDatas():void{// 格式化函数var myDateFormatterateFormatter=new DateFormatter();// 定义日期格式myDateFormatter.formatString="YYYY-MM-DD JJ:NN:SS";mx.controls.Alert.show(myDateFormatter.format(myData));}

Flex3语言参考手册中,关于DateFormatter的formatString是这样解释的:

The following table describes the valid pattern letters:

Pattern letter


Description


Y


Year. If the number of pattern letters is two, the year is truncated to two digits; otherwise, it appears as four digits. The year can be zero-padded, as the third example shows in the following set of examples:


YY = 05 YYYY = 2005 YYYYY = 02005

M


Month in year. The format depends on the following criteria:


If the number of pattern letters is one, the format is interpreted as numeric in one or two digits. If the number of pattern letters is two, the format is interpreted as numeric in two digits. If the number of pattern letters is three, the format is interpreted as short text. If the number of pattern letters is four, the format is interpreted as full text.

Examples:


M = 7 MM= 07 MMM=Jul MMMM= July

D


Day in month. While a single-letter pattern string for day is valid, you typically use a two-letter pattern string.

Examples:


D=4 DD=04 DD=10

E


Day in week. The format depends on the following criteria:


If the number of pattern letters is one, the format is interpreted as numeric in one or two digits. If the number of pattern letters is two, the format is interpreted as numeric in two digits. If the number of pattern letters is three, the format is interpreted as short text. If the number of pattern letters is four, the format is interpreted as full text.

Examples:


E = 1 EE = 01 EEE = Mon EEEE = Monday

A


am/pm indicator.


J


Hour in day (0-23).


H


Hour in day (1-24).


K


Hour in am/pm (0-11).


L


Hour in am/pm (1-12).


N


Minute in hour.

Examples:


N = 3 NN = 03

S


Second in minute.

Example:


SS = 30

Other text


You can add other text into the pattern string to further format the string. You can use punctuation, numbers, and all lowercase letters. You should avoid uppercase letters because they may be interpreted as pattern letters.

Example:


EEEE, MMM. D, YYYY at L:NN A = Tuesday, Sept. 8, 2005 at 1:26 PM

The default value is "MM/DD/YYYY".

相关知识

JSON后台转换日期格式
农业农村部:宠物饲料标签转换过渡期延长六个月
人话转换鸟语软件下载
投稿截止日期
提交截止日期
css 制作出窝旅行面试练习
动物AI照片生成:一键转换宠物肖像,打造专属卡通形象
动物语言信息转换与识别的方法和装置与流程
生产日期=分装日期?
麦当劳的qq宠物截止日期

网址: Flex中日期的转换 https://m.mcbbbk.com/newsview234550.html

所属分类:萌宠日常
上一篇: 催付话术模板
下一篇: 与业主沟通设计方案.doc 全文