Search code examples
apache-flexflex4.5datefield

Flex: Display month name in DateField control


I'm using the MX DateField control in Flex and want to display the date as 01 Jul 2011 or 01 July 2011. Does anyone know how to do this? I tried setting the formatString to "DD MMM YYYY" but it didn't work.


Solution

  • This works:

    <fx:Declarations>
        <mx:DateFormatter id="myDf" formatString="DD MMM YYYY"/>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            private function formatDate(date:Date):String{
                return myDf.format(date);
            }
        ]]>
    </fx:Script>
    <mx:DateField id="dateField" labelFunction="formatDate" />
    

    Found it in the LiveDocs at http://livedocs.adobe.com/flex/3/html/help.html?content=controls_12.html

    However this does not explain why the formatString property on the component does not work properly. I can confirm that it does not work as expected.

    Cheers