Monday, April 18, 2011

How to get GWT DateBox to show only the date part

While searching for tips on this, I found this useful blog post.
The only change i made is I replaced the deprecated function
getShortDateFormat with getFormat method from DateTimeFormat class.

With deprecated method:
So to format a DateBox to display a date like 06/26/2009
dateBox = new DateBox();
dateBox.setFormat(
new DateBox.DefaultFormat(
DateTimeFormat.getShortDateFormat()));

With new method:
fromDate = new DateBox()
fromDate.setFormat(
new DateBox.DefaultFormat(
DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)));

No comments:

Post a Comment