I noticed that the DateUtil.setDateInputFormatter method is deprecated in favor of the new setDateParser method. We have been using this code to make all of our date fields respect the current locale and it is working well.
Changing DateInputFormatter to DateParser introduced some strange problems. For example, we have a form that has four separate date fields with useTextField="true". Using the date picker next to any of these items results in the chosen date being put into the first field, not the one next to the picker you chose. Also, the date chooser doesn't disappear after you choose a date. You have to click somewhere else to make it go away.
Also, if you manually enter a valid date and try to submit the form the date field is cleared and, since they are required fields they are flagged with errors.
We've reverted back to using the deprecated method for now.
Code:
DateUtil.setDateInputFormatter(new DateInputFormatter() { @Override public Date parse(String dateString) { if (dateString==null) return null; else try { return DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).parseStrict(dateString); } catch (Exception e) { return null; } } });
Also, if you manually enter a valid date and try to submit the form the date field is cleared and, since they are required fields they are flagged with errors.
We've reverted back to using the deprecated method for now.
Comment