• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dates in JSP  RSS feed

 
Lucky Chawla
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I have a issue here , In my application I am getting a date from the user in a text box in string format, in my JSP page. Now I want to place a condition that the date entered should not be less than 1-APR-2006. So Can anyone tell me how to compare dates in JSP , If possible can anyone give me a short example ,
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37256
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lucky,
The first thing is to decide if you want to compare the dates on the server of the client. If the server, you compare the dates in Java and display an error message when repainting the screen. If the client, you compare the dates in JavaScript and display and alert (pop-up) message.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not JSP-specific. Moved to Java in General (beginner).
 
Sanjaya Sugiarto
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Date and Calendar classes there are methods after(Date when) and before(Date when) which return booleans.

Another alternative:
Calculate the dates being compared first into seconds or milliseconds than compare them.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!