--- In [email protected], "candysmate" <[EMAIL PROTECTED]> wrote:
>
> I'm trying to implement a DateFormatter function for a DataGridColumn
> as a labelFunction:
> 
> private function formatDate(item:Object, column:DataGridColumn):String
> {
>       dateFormatted = new DateFormatter();
>       dateFormatted.formatString = "DD-MM-YYYY"
>       return dateFormatted.format(item[column.dataField]);
> }
> 
> (MXML labelFunction="formatDate")
> 
> Not having any success right now. Any ideas please?
>

Date turned from SQL needed to be converted to a date object first
(oops!). This did it:

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

Reply via email to