aspose file tools*
The moose likes Java in General and the fly likes Date validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Date validation" Watch "Date validation" New topic
Author

Date validation

Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 232
Is there any REAL date validator-library available?

SimpleDateFormat (ok, it's just a formatter) is just too crippled. Even with setLenient(true); it passes ex: 11.12.2009kjdsjdsjjds.


SCJP 5.0, SCJD URLyBird 1.3.3, OCMJEA 5 (SCEA) Factory Homes
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

You can use the method with the ParsePosition, then check if the ParsePosition is at the end of the string.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 232
Thanks!
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3018
    
  10
Jari Timonen wrote:Is there any REAL date validator-library available?

SimpleDateFormat (ok, it's just a formatter) is just too crippled. Even with setLenient(true); it passes ex: 11.12.2009kjdsjdsjjds.

If you want stricter validation, you probably want setLenient(false), not true. It will still pass the example you give here if you use parse(String), since that's part of the method description. But setLenient(false) will at least make other aspects of the validation stricter.
Jari Timonen
Ranch Hand

Joined: Jan 16, 2004
Posts: 232
REAL validation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date validation