Java Developer
Java Developer

Reputation: 1901

how to Convert String to Date in flex?

Actually in my Flex Application DataGrid column getting one value like Sat Sep 1 00:00:00 GMT+0530 2012 how to convert this String as Date like 2012/09/01

i'm doing converting String Date but it giving null value...hear is my sample code

var startDS:String = saveDataGrid.selectedItem.startDate;
var sDate:Date=DateField.stringToDate(startDs,"YYYY/MM/DD");
Alert.show(sDate+"--===--"+startDS);//Alert giving  null--===--Sat Sep 1 00:00:00 GMT+0530 2012

please help...

Upvotes: 1

Views: 9340

Answers (1)

user1749053
user1749053

Reputation: 101

var startDS:String = "10022008";

var sDate:Date=DateField.stringToDate(startDS,"MMDDYYYY");

Alert.show(sDate+"--===--"+startDS);

You might also need to have a glance at http://livedocs.adobe.com/flex/3/html/help.html?content=formatters_4.html

output will be, "Thu Oct 2 00:00:00 GMT+0530 2008--===--10022008"

Upvotes: 2

Related Questions