<?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