• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date dd-Mon-yy is not returned correctly by Hibernate

 
Ajay Kamble
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having an Oracle database which is storing date as 'dd-Mon-yy', example date is 14-JAN-97 03.25.03 PM.

When I am getting this data from Hibernate I get date as- '14 January 2097'. How do I correct this?

Here is debug output: DEBUG - returning '14 January 2097' as column: CREATION8_10_0_

However if I execute the SELECT query against database then I get correct date: 14-JAN-97 03.25.03 PM.

Here is how my field is defined in Oracle-
Code:



And here is how it is mapped [mapping generated from Hibernate Tools],
Code:


I changed the type to 'timestamp' in mapping file, but it is still returning wrong date,

DEBUG - returning '2097-01-14 15:25:03' as column: CREATION8_10_0_
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write a type converter that corrects the bogus date in the DB?
 
Paul Clapham
Sheriff
Posts: 21586
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bogus indeed. Apparently lessons which should have been learned from the Y2K debacle were not universally learned.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That whole calling it "Y2K" thing always bothered me--isn't that what caused the problem in the first place, trying to save a couple of characters? ;)
 
Ajay Kamble
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This makes sense!

Now my problem is that I have legacy SQL Server database which is storing data as 2 digit year [YY]. I have to export this data to Oracle, 4 digit year.

But is there a solution to do this [maybe in Java]? How do I do the conversion?

-Regards
Ajay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic