In DateField Class there are methods like dateToString() stringToDate() toDateString(). so by using these methods we can define our code.
First import the required package and class in it.
import mx.controls.DateField;
The following example explains the need:
var birthday:String = “16/10/1984″;
var birthdayDate:Date = DateField.stringToDate(birthday, “DD/MM/YYYY”);
labelbirthday.text=birthdayDate.toDateString();
<mx:Label id=”labelbirthday” />
Here first the string birthday is converted into Date using the method stringToDate() and then convert it into DateString using the method toDateString();.Thats all the label prints the birthday in string format as “Tue Oct 16 1984″.
Now its similar to convert a Date into String using the methos,dateToString().The below Example shows it.
var today:Date = new Date();
var todayString:String = DateField.dateToString(today, “DD/MM/YYYY”);
todayLabel.text = todayString;
Now the todayLabel get the today date in string.Thats it Enjoy the code.


April 15, 2009 at 2:52 pm |
Hey, nice tips. Perhaps I’ll buy a glass of beer to that man from that chat who told me to visit your site