GXT set DateField value from string

Here is the code to set GXT datefield value from the date string.

String sdate="24-01-2012";  //24 Jan 2012
DateTimeFormat dformat = DateTimeFormat.getFormat("dd-MM-yyyy");
DateField date2 = new DateField();
date2.getPropertyEditor().setFormat(dtFormat);
Date dDate= dformat.parse(sdate);
date2.setValue(dDate);

1 comments:

Andrés Akle said...

Thanks for the post, it was very usefull.
There is a little error:
date2.getPropertyEditor().setFormat(dtFormat);
should be:
date2.getPropertyEditor().setFormat(dformat);

 
Copyright © peyotest