Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

MS SQL server datetime and Java Date comparision problem

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello I have date time problem in Hibernate , in hibernate mapping i have provided the type "timestamp" , In pesistent class I have a java.util.Date type varialbe in which i m saving current date time, in MS sql server table i have datetime type column to persist this variable.

following is the date time before storing and after loading from database :the problem is that
sometimes it returns true indicating that the date is same ,but someimes it gives false :
It should be always true while i compare both objects that is before persistence and after loading from the data base the persisted value for tha object:
i think this problem iss not bcoz of hibernae , it is MS sql server datetime and java Date calss type problem........plz eply me as soon as poosible , thanks in advance!

before storing Time obj2.getDate() = Wed Jun 23 10:21:56 GMT+05:00 2004
loading from database Time obj1.getDate()= 2004-06-23 10:21:56.093
Obj1.getDate().equals(obj2.getDate()) = true


before storing Time obj2.getDate()= Wed Jun 23 10:23:22 GMT+05:00 2004
loading from database Time obj1.getDate() = 2004-06-23 10:23:22.917
Obj1.getDate().equals(obj2.getDate()) time = false

before storing Time obj2.getDate() = Wed Jun 23 10:26:07 GMT+05:00 2004
loading from database Time obj1.getDate() = 2004-06-23 10:26:07.023
Obj1.getDate().equals(obj2.getDate()) Time = false

before storing Time obj2.getDate() = Wed Jun 23 10:27:18 GMT+05:00 2004
loading from database Time obj1.getDate() = 2004-06-23 10:27:18.497
Obj1.getDate().equals(obj2.getDate()) Time = true


before storing Time obj2.getDate() = Wed Jun 23 10:29:36 GMT+05:00 2004
loading from database Time obj1.getDate() = 2004-06-23 10:29:36.547
Obj1.getDate().equals(obj2.getDate()) Time = false
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"famous creature",

Please take a moment to read our naming policy and go here to edit your displayed name into something compliant with the said policy.

Thank you.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
....or just repost your question with a different word ordering in the title ;-)
 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic