• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Dates in JSP

 
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 ,
 
author & internet detective
Posts: 39433
768
Eclipse IDE VI Editor Java
  • 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.
 
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not JSP-specific. Moved to Java in General (beginner).
 
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.
 
What does a metric clock look like? I bet it is nothing like this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!