• 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;
        }
    }

  • 相关阅读:
    void及void指针含义的深刻解析
    对个人站长职业前景的探讨之路在何方?
    Swift编程语言学习4.3—— 控制语句
    二分查找
    分布式文件系统
    常见浏览器兼容性问题与解决方式
    OutputDebugString()
    眼睛的颜色
    SVM-支持向量机算法概述
    Android学习笔记(四十):Preference的使用
  • 原文地址:https://www.cnblogs.com/taobataoma/p/1037015.html
Copyright © 2020-2023  润新知