I'm working my way through the various i18n issues and have found what seems like the perfect solution for dates using GWTs i18n methodology. I put the following code at the start of my module and it seems to do exactly what I want, but please let me know if this is not the best approach. Locale is specified on the URL.
The next thing I need to tackle is number formatting. I'd like to be able to specify a "money" data type that will format 12345.67 as either $12,345.67 or £12,345.67 or € 12.345,67 depending on the locale. And for integers or other non-currency fields I'd like to do the same so 12345 becomes 12,345 or 12.345 and 12345.6789 becomes 12,345.6789 or 12.345,6789 depending on the locale.
What is the recommended approach for this?
Code:
DateUtil.setDateInputFormatter(new DateInputFormatter() { @Override public Date parse(String dateString) { return DateTimeFormat.getShortDateFormat().parse(dateString); } }); DateUtil.setShortDateDisplayFormatter(new DateDisplayFormatter() { @Override public String format(Date date) { return DateTimeFormat.getShortDateFormat().format(date); } }); DateUtil.setNormalDateDisplayFormatter(new DateDisplayFormatter() { @Override public String format(Date date) { return DateTimeFormat.getMediumDateFormat().format(date); } });
What is the recommended approach for this?
Comment