Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i convert string datatype to date datatype in flex

I have to convert one string type field to date datatype in flex.

What can I do solve this problem?

like image 435
Nidhi Avatar asked May 12 '10 12:05

Nidhi


2 Answers

import mx.controls.DateField;

var dateString:String = " 25/02/2009";
var date:Date= DateField.stringToDate(dateString,"DD/MM/YYYY");

with credit to: http://amthekkel.blogspot.com/2009/02/flex-converting-date-string-to-date.html

like image 172
invertedSpear Avatar answered Sep 30 '22 20:09

invertedSpear


var str:String = "25/02/2009"
var d:Date = new Date(str);

or

we can use a custom DateUtils class

package 
{
  import mx.formatters.DateFormatter;

  public class DateUtils extends DateFormatter
 {
    public function DateUtils()
   {
     super();
   }



  public static function parseString (str:String):Date {
      return parseDateString(str);
  }

 }
}
like image 24
girija Avatar answered Sep 30 '22 20:09

girija