aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 9317
    
109

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Comparing dates in hibernate
 
Similar Threads
Dynamic EJB QL
converting sqldates?
hibernate problem.
Calendar() / Date() bug ???
Date 01/01/1970 returning non-zero value for time