Nov 23, 2010

gwt datetimeformat

DateBox startDate = new DateBox();
DefaultFormat dateFormat = new DefaultFormat(){
DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("MM/dd/yyyy");
@Override
public String format(DateBox box, Date date){
           if (date == null) {
               return "";
            } else {
                return dateTimeFormat.format(date);
            }
  }
};
// attaching formatter
startDate.setFormat(dateFormat);
That's all. Your date would be formatted as MM/dd/yyyy
You can find some more formatters at Google gwt site.
Or GWT in Practice
bye,
Dor

No comments:

Post a Comment