Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date comparision

 
Lalit Vora
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

can someone guide me please how to compare date i.e user inputed date with system date.

I have user inputted date in mm/dd/yyyy formate and i have default date as systemdate-1. Both i have using simpledate format.
I want to compare that user input date should not be greater than systemdate -1 I have system-1 date generated also. I dont know how to compare them. Please some one can help me with that.

Thank you very much
Lalit
 
Durgaprasad Guduguntla
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do this using custom validator. My following posting might help you.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you have converted the input date to a java.util.Date, you can then use the "before" or "after" methods of that class to compare it with the system date:

if (inputDate.after(systemdate-1) { // do something }
 
Lalit Vora
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Merrill

Thanks alot its working now
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic