Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Switch from deprecated DateInputFormatter to DateParser causes problems

    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.
    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;
    			}			
    	}
    });
    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.

    #2
    We have actually just resolved an issue with Dateutil.setDateParser() today. Can you check with a new nightly. Let us know if you keep seeing it and we'll take a look.

    Thanks

    Comment

    Working...
    X