views:

27

answers:

1

I have to select date from date field in flex and store that date into SqlLite database. I am inserting date by using this code :

dbInsertDate = datechooser.selectedDate.getFullYear().toString()+'0'+(datechooser.selectedDate.getMonth()+1).toString()+"-0"+datechooser.selectedDate.getDate().toString();

where dbInsertDate is string type variable and datechooser is date field id. It stores the date in database in a format like 2455361.5. I want to store date in either dd-mm-yyyy format or yyyy-mm-dd format in the database. How can i store date in yyyy-mm-dd format in SqlLite using flex ?

Thanks

A: 

You can use a DateFormatter:

var formatter:DateFormatter = new DateFormatter();
formatter.formatString = "DD-MM-YYYY";
var result:String = formatter.format(datechooser.selectedDate);

If you use localization you can "translate" the format string to the needed format.

hering