flex格式化日期

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>
    <![CDATA[
        import mx.formatters.*;
        [Bindable]
        private var time:Date=new Date();  
        private function TestDateTimeToString():void
        {
            var fr:DateFormatter=new DateFormatter();
            fr.formatString="YYYY-MM-DD JJ:NN:SS";
            currentTimeAS3.text=fr.format(time);

        }

    ]]>   
</mx:Script> 
 <mx:DateFormatter id="dateFormat" formatString="YYYY-MM-DD JJ:NN:SS"/>
 <mx:Panel width="100%" height="100%">
  <mx:Label id="currentTimeText" text="當前日期:"/>
  <mx:Label id="currentTime" text="{dateFormat.format(time)}"/>
        <mx:Button label="調用AS3轉換當前日期" click="TestDateTimeToString()"/> 
  <mx:Label id="currentTimeAS3" text="現在的時間還沒有被轉換" />         
 </mx:Panel>
</mx:Application>

PS:防止以後忘記

轉載地址:http://flex2.group.iteye.com/group/blog/208248

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章