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

Comparing dates in hibernate

 
Bob Green
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my code:



This is not working because
dob.getTime() returns "Wed Apr 01 12:00:00 MST 1970"
and
Person.DOB returns "1970-03-01"

How do I make it to work?

Any help is greatly appreciated!

Rob

[ Edited to use code tags - Paul Sturrock ]
[ November 20, 2006: Message edited by: Paul Sturrock ]
 
Greg Hemlock
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calendar.MONTH is zero based. dob.set(Calendar.MONTH, 2) should get you closer.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better still, use:

 
sandy comp
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems Person.DOB returns string. You can format date to string and then compare. This happnes because if we say resultset.getString("DOB") where "DOB" is date column.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic