Last time when I tried, this was working for me. It *may* give you an idea.
See the labelFunction...

<mx:DataGridColumn dataField="availabilityDate" headerText="Availability
Date" editable="false" labelFunction="formatDate"/>

private function formatDate(item:Object, column:DataGridColumn):String {
        var dateFormatted:DateFormatter = new DateFormatter();
        dateFormatted.formatString = "DD-MM-YYYY";
        var rawDate:Date = new Date(item[column.dataField]);
        return dateFormatted.format(rawDate) as String;
}


Thanks.

2008/7/17 Dominic Pazula <[EMAIL PROTECTED]>:

>   I cannot seem to get the proper year out of a DateFormatter.
>
> Can someone tell me what I am doing wrong:
>
> I have a component:
> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"; width="100%"
> height="100%" creationComplete="init()">
> <mx:Script>
> <![CDATA[
> import mx.collections.ArrayCollection;
>
> [Bindable] private var date:Date = new Date();
> [Bindable] private var ac:ArrayCollection =
> new ArrayCollection();
>
> private function init():void{
> var obj:Object = new Object;
> obj.date = date;
> obj.datetime = date;
> ac.addItem(obj);
> }
> ]]>
> </mx:Script>
>
> <mx:DateFormatter id="fmtDate" formatString="MM-DD-YYYY"/>
> <mx:AdvancedDataGrid dataProvider="{ac}" height="100%"
> width="100%">
> <mx:columns>
> <mx:AdvancedDataGridColumn dataField="date"
> formatter="{fmtDate}"/>
> <mx:AdvancedDataGridColumn dataField="datetime"/>
> </mx:columns>
> </mx:AdvancedDataGrid>
>
> </mx:Canvas>
>
> The Date column resolves to "07-16-400". The Datetime column to "Wed
> Jul 16 19:08:39 GMT-0400 2008".
>
> Why does my year show up as 400???
>
>  
>

Reply via email to