Formatting the SelectedDate in DateChooser

ActionScript 3.0,Adobe Flex 31 March 2010 | 1 Comment

I was suddenly struck up with this DateChooser as my the date object doesn’t recognize the dash as a valid separator.

var date:Date = new Date("2009/12/30");
myDateChooser.selectedDate = date;

The above one works, but if you take the below one it does not work.

var date:Date = new Date(“2009-12-30″);
myDateChooser.selectedDate = date;

The solution for this is DateFormatter.

var DateStr:String = dateFormatter.format(“2009-12-30″);
DateChooser.selectedDate = new Date(DateStr);

<mx:DateFormatter id=”dateFormatter” formatString=”MMM D, YYYY”/>

<mx:DateChooser showToday=”false” id=”DateChooser” x=”130″ y=”55″  width=”159″></mx:DateChooser>

This will solve your problem. Have a nice day.

One Response on “Formatting the SelectedDate in DateChooser”

  1. Pretty nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!

Leave a Reply