Question : Flex 3 Datefield and DateChooser

Hello,

Please see attached picture. In the DateChooser I changed the day and month (language) names with dayNames and monthNames. The DateField still shows the chosen date in English, where or how can I change that?

Thank you.
Attachments:
 
Adobe Flex Datefield
Adobe Flex Datefield
 

Answer : Flex 3 Datefield and DateChooser

Greetings,

You can use DateField's labelFunction to show custom text formatting:

Below is the working code snippet:

Hope this will help.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:Script>
		<![CDATA[
			private var dayNames:Array = ["A", "B", "C", "D", "E", "F", "G"];
			private var monthNames:Array = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
			
			private function formatDate(date:Date):String 
			{
				if (!date)
				{
					return "";
				}
				var monthDay:String = String(date.getDate());
				var monthName:String = monthNames[date.getMonth()];
				var year:String = String(date.getFullYear());
				
				return monthDay + " " + monthName + " " + year;
            }
            
            private function initDate():void
            {
            	df.dayNames = dayNames;
            	df.monthNames = monthNames; 
            }
		]]>
	</mx:Script>
    <mx:DateField id="df" creationComplete="initDate()" labelFunction="formatDate" parseFunction="null"/>
</mx:Application>
Random Solutions  
 
programming4us programming4us