1 Reply Latest reply on Jan 15, 2013 4:24 PM by jfb00

    DateFormatter For DataGrid Not Working


      I am currently using flash 4.6 and i am trying to get my dates to format correctly in one of my columns the following codes i am using is below, this doesn't work at all. What am i doing wrong?


      private function formatDate(item:Object, column:DataGridColumn):String


                      var df:DateFormatter = new DateFormatter();

                      df.formatString = "MM/DD/YY";


                      if (column.dataField == "eventdate") {

                          return df.format(item.eventdate);






      and in my DataGrid is


      <s:GridColumn width="90" headerText="Reservation Date"

                                            resizable="true" labelFunction="formatDate"></s:GridColumn>

        • 1. Re: DateFormatter For DataGrid Not Working
          jfb00 Level 3


          Try this:


          private function formatDate(item:Object, dgColumn:DataGridColumn):String

                if(item.hasOwnProperty(dgColumn.dataField) && item[dgColumn.dataField] != null)


                          return formatDate(item[dgColumn.dataField]);



                          return null;

                      return item[dgColumn.dataField];



                  public function formatDate(val:Date):String


                      var dateFormatter:DateFormatter = new DateFormatter();

                      dateFormatter.formatString = "MM/DD/YYYY";

                      return dateFormatter.format(val);