Wednesday, May 9, 2007

Flex Date Formatter

Recently I was working on Flex Builder 2. I must say that its a fine tool from Adobe. Good Job !!
Formatting dates is a problem everywhere and in flex this issue is handled quite nicely.
I have the following example:


var df:DateFormatter = new DateFormatter;

df.formatString="DD-MMM-YYYY";
var dob:String = 28/11/1985;
dob=df.format(dob);

These lines convert the dates into the desired format.

2 comments:

Anonymous said...

sweet!... with just a little modification... it works!
thank you so much :)

Unknown said...

I tried this.. and keep getting the compiler error:

"Error: Access of undefined property df."
df.formatString = "HH:NN:SS";

I thought "formatString" was a PUBLIC property of DateFormatter. I don't understand why the compiler keeps complaining. Any advice?