File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes datePatternStrict : checking yyyy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "datePatternStrict : checking yyyy" Watch "datePatternStrict : checking yyyy" New topic

datePatternStrict : checking yyyy

Venkat Babu
Ranch Hand

Joined: Jan 12, 2007
Posts: 47

I am using datePatternStrict for one of the date field.

<field property="corpDate" depends="date">
<arg0 key="error.incdate"/>

But I need to check the year is from 1900 to 2000. The user cannot
enter 0001 or 1899. I am not sure how I can do this. Could someone give me some idea? Thanks.
Sri Anand
Ranch Hand

Joined: Mar 06, 2005
Posts: 392
You will have to write your own custom validation , I guess Struts validation only checks the pattern, If implementing a cutom validation is too much of pain you would end up writing a custom Java script
Venkat Babu
Ranch Hand

Joined: Jan 12, 2007
Posts: 47
Thanks a lot.
Nick Williamson
Ranch Hand

Joined: Jan 06, 2007
Posts: 73
the easiest way to do that is to override the validate method on your form, call super, then check if the date is null or what have you, then get the year and validate it there. That way all your validation is contained in the form. Or you could try min/max with dates (I've never tried that but it might be worth a shot).
I agree. Here's the link:
subject: datePatternStrict : checking yyyy
jQuery in Action, 3rd edition