在flex中在类是datagrid 等list控件使用labelFunction格式各种文本信息,如事件等可以使用
?mx:dateformatter 格式化日期时间,但是在许多编码中使用编程式格式化,但是flex中格式化
的各种参数和java中有一些不同,造成使用过java的程序员有点头疼,命名在java中可以的格式
在flex中不通过:请看下面的各种样式的格式化表达式的应用:
?
?如flex中分钟使用NN表示等各种格式
?private static var dateFormatter:DateFormatter = new DateFormatter();
??/**
?? * 格式化日期,封装mx.formatters.DateFormatter类
?? * 可以在模式字符串中添加其它文本,以进一步设置字符串格式。可以使用标点、数字和所有小写字母。
?? * 应该避免使用大写字母,因为大写字母可能被解读为模式字母。
?? *?
?? * 年份
?? * YY = 05
?? * YYYY = 2005
?? * YYYYY = 02005
?? *?
?? * 一年中的月份
?? * M = 7
?? * MM= 07
?? * MMM=Jul
?? * MMMM= July
?? *?
?? * 一月中的日期
?? * D=4
?? * DD=04
?? * DD=10
?? *?
?? * 星期中的天
?? * E = 1
?? * EE = 01
?? * EEE = Mon
?? * EEEE = Monday
?? *?
?? * A am/pm 标记。?
?? *?
?? * J 一天中的小时数 (0-23)。?
?? *?
?? * H 一天中的小时数 (1-24)。?
?? *?
?? * K am/pm 中的小时数 (0-11)。?
?? *?
?? * L am/pm 中的小时数 (1-12)。?
?? *?
?? * 小时中的分钟数
?? * N = 3
?? * NN = 03
?? *?
?? * 分钟中的秒数
?? * SS = 30
?? *?
?? * @param value 日期
?? * @param formatString 格式
?? * @param return 指定格式的字符串
?? */
??public static function formatDate(value:Object,formatString:String="YYYY-MM-DD"):String {
???if (value == null || StringUtil.trim(value.toString()).length <= 0) {
????return "-";
???}
???dateFormatter.formatString = formatString;
???return dateFormatter.format(value);
??}
转载地址:http://www.voidcn.com/article/p-aygbbspt-rr.html