File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Date Formatting Problem with Validator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Date Formatting Problem with Validator" Watch "Date Formatting Problem with Validator" New topic
Author

Date Formatting Problem with Validator

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1043
Hello,

I have an entry in my validation.xml file for a form where I'm trying to make sure the user can't enter a date like "01/01/20234".

However, what I entered below does not work so I must be doing something wrong?

<field property="fDate" depends="date">
<arg0 key="label.fDate"/>
<var><var-name>datePattern</var-name><var-value>MM/dd/yyyy</var-value></var>
</field>

I don't want to use datePatternStrict since the user may forget to add two digit months and years.

Although, the date validator does seem to validate some date entry issues, it fails when I enter more than 4 digits for the year, which then crashes the application due to a date transformation for an Oracle Query.

Any suggestions would be welcome!

Thanks.

Mike
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Its strange issue when you enter more than four digits for the year and its get validated(May be I'm missing something very basic).
Try using "MM/dd/yy" pattern and also look at the java.text.SimpleDateFormat class summary.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date Formatting Problem with Validator
 
Similar Threads
required validation on integer field not working
Struts Date validation using validator
double validation not catching text
Having problem with struts validator for error message
datePatternStrict : checking yyyy