Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
Valang to validate the format of date and time? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Valang to validate the format of date and time?

    Hi, I hope to use Valang to validate the format of input date and time, MM/dd/yyyy HH:mm:ss. I read Valang's project document and the book of Expert Spring MVC and Web Flow, but failed to find any meaningful example for that. Does anybody have an example to share? Or a pointer to an example?

    Cheers!
    David

  • #2
    Originally posted by MDDZ View Post
    Hi, I hope to use Valang to validate the format of input date and time, MM/dd/yyyy HH:mm:ss. I read Valang's project document and the book of Expert Spring MVC and Web Flow, but failed to find any meaningful example for that. Does anybody have an example to share? Or a pointer to an example?

    Cheers!
    David
    When I have looked at this I just get a bind error if the date or time is in the wrong format, so it's just a case of configuring your property editor registrar to bind with a specific date or time format, and then set the property registrar on your webflow or MVC action.

    This is how I did it:
    Code:
    public class BlaBlaPropertyEditorRegistrar implements PropertyEditorRegistrar {
    	
    	
    	public void registerCustomEditors(PropertyEditorRegistry registry) {
    		
    		//date
    		
    		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
    		simpleDateFormat.setLenient(false);
    		registry.registerCustomEditor(Date.class, new CustomDateEditor(simpleDateFormat, true,10));
    		
    	
    	}
    }

    Comment

    Working...
    X