Using a custom DateFormatProvider in GWT

68 views
Skip to first unread message

Panam

unread,
Jun 8, 2011, 12:17:29 PM6/8/11
to Google Web Toolkit
Hi,

since the J2EE runtime seems to revert to some inappropriate standard
locale when using the actual locale "ta-IN", I've written a customized
DateFormatProvider and successfully deployed it to the application
server. It looks like this:

public class TamilNaduDateFormatProvider extends
java.text.spi.DateFormatProvider{

@Override
public DateFormat getTimeInstance(int style, Locale locale) {
return DateFormat.getTimeInstance(style, Locale.UK);
}

@Override
public DateFormat getDateInstance(int style, Locale locale) {
return DateFormat.getDateInstance(style, Locale.UK);
}

@Override
public DateFormat getDateTimeInstance(int dateStyle, int timeStyle,
Locale locale) {
return DateFormat.getDateTimeInstance(dateStyle, timeStyle,
Locale.UK);
}

@Override
public Locale[] getAvailableLocales() {
return new Locale[]{new Locale("ta", "IN")};
}

}

It needs to be packed into a jar with some meta information and
deployed to the runtime's lib/ext directory.
Here is some background: http://download.oracle.com/javase/6/docs/technotes/guides/extensions/index.html
For server code, this works fine. However, the GWT-UI in my case still
uses that inappropriate default locale (even after doing a
recompilation using the extended (by the customized
DateFormatProvider) runtime.
So my question is: How does GWT determine the proper date formatting
for the locale sent from the browser and how could I plug-in into this
system to have "ta-IN" properly supported?
Apparently, the standard Java mechanism does not work, or am I wrong?
Is it because GWT uses the SDK rather than the runtime? I tried to
create the corresponding lib/ext Folder even in the SDK and put the
jar there but this also did not help...

Regards,
panam

John A. Tamplin

unread,
Jun 16, 2011, 11:37:04 PM6/16/11
to google-we...@googlegroups.com
GWT uses the data from the Unicode CLDR, and supports ta and ta_LK, so ta_IN should get the ta defaults, which should be appropriate for IN.  If you believe there should be a specialization for ta in India, then I suggest filing a bug against CLDR to add it.

Aside from that, search for *_ta.* under user/src/com/google/gwt/i18n and make a copy under *_ta_IN.* and edit it as needed.  You could put those files in your own project and GWT will use them if they are on the classpath.  

Panam

unread,
Jul 29, 2011, 10:43:32 AM7/29/11
to Google Web Toolkit
Thanks, just the information I needed.
Reply all
Reply to author
Forward
0 new messages