Formatting dates using the DateFormatter

简介:
Another basic little example showing how to format the text in a DateField control using the DateFormatter and the DateField control’s  labelFunction  property. This entry also shows the pretty basic trick of creating a separate ActionScript class file that holds the day names as constants so you don’t constantly have to think whether Monday is day 0 or day 1 (hint: it is day 1).
<? xml version="1.0" encoding="utf-8" ?>
< mx:Application  xmlns:mx ="http://www.adobe.com/2006/mxml"  layout ="vertical"  verticalAlign ="middle"  backgroundColor ="white" >

    
< mx:Script >
        
<![CDATA[
            private function doLabel(item:Date):String {
                return dateFormatter.format(item);
            }
        
]]>
    
</ mx:Script >

    
< mx:DateFormatter  id ="dateFormatter"  formatString ="MMM D, YYYY" />

    
< mx:DateField  todayColor ="red"  labelFunction ="doLabel"  firstDayOfWeek ="{Days.MONDAY}"   />

</ mx:Application >

Days.as
// ActionScript file
package {
    public class Days {
        public static const SUNDAY:uint = 0;
        public static const MONDAY:uint = 1;
        public static const TUESDAY:uint = 2;
        public static const WEDNESDAY:uint = 3;
        public static const THURSDAY:uint = 4;
        public static const FRIDAY:uint = 5;
        public static const SATURDAY:uint = 6;
    }
}


    本文转自 OldHawk  博客园博客,原文链接:http://www.cnblogs.com/taobataoma/archive/2008/01/13/1037015.html ,如需转载请自行联系原作者


相关文章
|
4月前
|
Ubuntu Linux Python
UserWarning: Glyph 27668 (\N{CJK UNIFIED IDEOGRAPH-6C14}) missing from current font.
UserWarning: Glyph 27668 (\N{CJK UNIFIED IDEOGRAPH-6C14}) missing from current font.
212 2
|
传感器 监控 安全
【Matter】Matter学习笔记1(下)
【Matter】Matter学习笔记1
12174 1
|
传感器 网络协议 安全
【Matter】Matter学习笔记1(上)
【Matter】Matter学习笔记1
724 1
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
UserWarning: Glyph 28857 (\N{CJK UNIFIED IDEOGRAPH-70B9}) missing from current font. FigureCanvasA
1005. Spell It Right (20)
#include using namespace std; int main(int argc, const char * argv[]) { string s; cin >> s; int sum = 0, len = (int)s.
876 0
|
关系型数据库 MySQL
|
关系型数据库 MySQL
|
PHP 开发工具 git