How to set the format for a DateBox?

5,906 views
Skip to first unread message

Stevko

unread,
Nov 23, 2009, 3:11:35 PM11/23/09
to Google Web Toolkit
I've setup DateTimeFormat and TimeZone objects within my application
based on user preferences.

com.google.gwt.i18n.client.DateTimeFormat
com.google.gwt.i18n.client.TimeZone


How do I set the format for a DateBox ?

DateBox.Format does not allow for the setting of a custom format.
http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/user/datepicker/client/DateBox.Format.html

Thomas Broyer

unread,
Nov 23, 2009, 5:52:28 PM11/23/09
to Google Web Toolkit


On 23 nov, 21:11, Stevko <andy.ste...@gmail.com> wrote:
> I've setup DateTimeFormat and TimeZone objects within my application
> based on user preferences.
>
> com.google.gwt.i18n.client.DateTimeFormat
> com.google.gwt.i18n.client.TimeZone
>
> How do I set the format for a DateBox ?
>
> DateBox.Format does not allow for the setting of a custom format.http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/g...

Yes it does:

myDateBox.setFormat(new DateBox.DefaultFormat
(DateTimeFormat.getFormat("EEEE, MMMM dd, yyyy")));

or you could use your own custom Datebox.Format implementation:

myDateBox.setFormat(new MyCustomDateBoxFormat());

Stevko

unread,
Nov 23, 2009, 11:28:10 PM11/23/09
to Google Web Toolkit
Thanks Thomas,
I missed that ctor when looking at the interface spec.

The final syntax is a bit twisted...

myDateBox.setFormat( new DateBox.DefaultFormat( myDateTimeFormat ) );

Care to guess what timezone GWT's java.util.Date and DateBox are
using?
Perhaps the browser's timezone, server's timezone, GMT, or something
else?

Thomas Broyer

unread,
Nov 24, 2009, 4:30:02 AM11/24/09
to Google Web Toolkit
Dates are in the client (browser) timezone.

Stevko

unread,
Nov 24, 2009, 12:12:04 PM11/24/09
to Google Web Toolkit

Cool! Thanks again for the valuable info.
Reply all
Reply to author
Forward
0 new messages