i have a created a date related application in which i convert date into different string and number format like DD-MM-YYYY , DD-MM-YY etc
3 Answers
If the answer of Sagar works for you, then just per coincidence: it just converts the Date to what Date thinks is appropriate on your platform, which may or may not be appropriate on the platform of your customers (which actually make the answer dangerous, because it looks like being right and then eventually blows your app up).
(Updated) To take control of the formatting using Flex 4.5 you should use spark.formatters.DateTimeFormatter which belongs to Flex globalisation strategy.
In this class you can set a conversion pattern to your liking (using date/time pattern or just predefined shortcuts like DateTimeStyle constants) or just leave it as it is, which will use a current platform locale.
Look here: Flex 4.5 DateTimeFormatter Reference
EDIT
I overlooked the "flex 3" in the question: in case of Flex 3 Adobe suggests to use mx.formatters.DateFormatter. The reference: Flex 3 DateFormatter Reference

- 12,796
- 1
- 30
- 32
-
1thanks for the answer but i am currently using Flex version 3.0 – Dec 30 '11 at 09:57
-
and you even specified it in the question... mea culpa! Then use mx.formatters.DateFormatter. – Tomasz Stanczak Dec 30 '11 at 10:36
hi you can get the answer in below code..
var d:Date = new Date();
Alert.show(d.toDateString(),"toDateString");
Alert.show(d.toLocaleDateString(),"toLocaleDateString");
Alert.show(d.toLocaleString(),"toLocalString");
Alert.show(d.toLocaleTimeString(),"toLocalTimeString");
Alert.show(d.toString(),"toString");
Alert.show(d.toTimeString(),"toTimeString");
Alert.show(d.toUTCString(),"toUTCString");
there are many options to convert date into string. you can choose any one as per your requirement.
Have a nice D@Y...

- 1,442
- 2
- 12
- 39
For those journeymen wondering how they can format a Date object in pure AS3; then consider having a peek at the DateUtils static helper class which is part of AS3Commons Lang.

- 6,119
- 2
- 26
- 28