• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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_
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Write a type converter that corrects the bogus date in the DB?
 
Sheriff
Posts: 28360
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
It's just like a fortune cookie, but instead of a cookie, it's pie. And we'll call it ... tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic