• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date validation

 
Jari Timonen
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Rob Spoor
Sheriff
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the method with the ParsePosition, then check if the ParsePosition is at the end of the string.
 
Jari Timonen
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
Mike Simmons
Ranch Hand
Posts: 3028
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
REAL validation
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic