Use DateFormatter to format Date value : DateFormatter « Data Model « Flex






Use DateFormatter to format Date value

Use DateFormatter to format Date value
    


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >

    <mx:Script>
        
        
            private function formatData(item:Object):String 
            {
                return dateF.format(item.data);
            }
            
            private function changeData(obj:Object):void
            {
                dateTxt.text =  dateF.format(obj.data);
            }
      
    </mx:Script>

    <mx:ArrayCollection id="myAC">
        
            <mx:Object label="{new Date(2010,1,1)}" data="{new Date(2010,1,1)}"/>
            <mx:Object label="{new Date(2010,1,2)}" data="{new Date(2010,1,2)}"/>
            <mx:Object label="{new Date(2010,1,3)}" data="{new Date(2010,1,3)}"/>
        
    </mx:ArrayCollection>       
    
    <mx:DateFormatter id="dateF" formatString="EEE, DD/MMM/YYYY" />

    <mx:TextInput id="dateTxt" editable="false"  />

    <mx:ComboBox id="myCombo" dataProvider="{myAC}"
        labelFunction="formatData"
        change="changeData(myCombo.selectedItem)" />
    
</mx:Application>

   
    
    
    
  








Related examples in the same category

1.Formatting the Date as a Date objectFormatting the Date as a Date object
2.Formatting the Date as a StringFormatting the Date as a String
3.DateFormatter format string MM/DD/YYDateFormatter format string MM/DD/YY
4.DateFormatter format string "MMM DD, YYDateFormatter format string
5.DateFormatter format string MMMM DD, YYYYDateFormatter format string MMMM DD, YYYY
6.Set format string for DateFormatterSet format string for DateFormatter
7.Data Formatting with DateFormatterData Formatting with DateFormatter
8.Declare a DateFormatter component with an MM/DD/YYYY date format, and binds the formatted version of a Date object
9.Declare a DateFormatter with an MM/DD/YYYY date formatDeclare a DateFormatter with an MM/DD/YYYY date format
10.Using the DateFormatter classUsing the DateFormatter class
11.Formatting dates using the DateFormatter
12.Use a DateFormatter object to do the formattingUse a DateFormatter object to do the formatting
13.declares a DateFormatter component with an MM/DD/YYYY date formatdeclares a DateFormatter component with an MM/DD/YYYY date format
14.An error handler function for DateFormatterAn error handler function for DateFormatter
15.DateFormatter and parametersDateFormatter and parameters
16.Example Date FormatterExample Date Formatter
17.DateField FormatterDateField Formatter