Skip to content

Instantly share code, notes, and snippets.

@rjattrill
Last active October 7, 2015 02:58
Show Gist options
  • Save rjattrill/3094094 to your computer and use it in GitHub Desktop.
Save rjattrill/3094094 to your computer and use it in GitHub Desktop.
Format Date in DataGrid
<fx:Declarations>
<s:DateTimeFormatter id="dateTimeFormatter" dateTimePattern="yyyy-MM-dd"/>
</fx:Declarations>
<s:DataGrid id="dg" height="100%" width="100%" borderVisible="false">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="Date" headerText="Date" formatter="{dateTimeFormatter}"/>
</s:ArrayList>
</s:columns>
</s:DataGrid>
<fx:Script>
<![CDATA[
import spark.formatters.DateTimeFormatter;
private function formatDate (item:Object, column:GridColumn):String {
var df:DateTimeFormatter = new DateTimeFormatter();
df.dateTimePattern = "dd-MMM-yyyy";
var value:Object = item[column.dataField];
return df.format(value);
}
]]>
</fx:Script>
<s:DataGrid id="dg" height="100%" width="100%" borderVisible="false">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="TRAN_DATE" headerText="Transaction Date" labelFunction="formatDate"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment