Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Validate Date in JSP/Java  RSS feed

 
Faz Rashad
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there an equivalent to the VB "isDate" function?

What is the easiest way to validate dates entries in JSP/Java? I have a calendar in place, but the user might choose to enter the date manually. I need to be able to check if the date is valid before executing a SQL query.

The validation does not have to be done by the client (through java script), since this page will not be heavely used.

Thanks "isDate"
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36426
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faz,
Your thoughts to do the validation on the server are good. The user could turn off javascript altogether.

You can instantiate a GregorianCalendar object with the given date and set lenient to false.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!