wood burning stoves*
The moose likes Object Relational Mapping and the fly likes Comparing dates in hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Comparing dates in hibernate" Watch "Comparing dates in hibernate" New topic
Author

Comparing dates in hibernate

Bob Green
Ranch Hand

Joined: Feb 29, 2004
Posts: 93
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

Joined: Nov 17, 2006
Posts: 1
Calendar.MONTH is zero based. dob.set(Calendar.MONTH, 2) should get you closer.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

Better still, use:



[My Blog] [JavaRanch Journal]
sandy comp
Greenhorn

Joined: Aug 11, 2001
Posts: 10
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.


Design and programming are human activities; forget that and all is lost.
 
 
subject: Comparing dates in hibernate