File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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: 230
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: 19543
    
  16

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: 230
Thanks!
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2969
    
    9
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: 230
REAL validation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date validation
 
Similar Threads
Displaying the Date - Issue
Another format check :P
Date or Timestamp?
How to Ping Multiple Servers
WA #1.....word association