-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Julian Date to java.util.Date
PostPosted: Tue Mar 21, 2006 1:57 pm 
Newbie

Joined: Tue Mar 21, 2006 1:40 pm
Posts: 1
Location: Longmont, CO
I just started using Hibernate 3.0. I'm waiting for Amazon to deliver Hibernate in Action but in the mean time I have a small issue.

I'm pointing my prototype application to an AS400/DB2 database which formats dates as Julians. I got Hibernate working by putting the following in my hbm.xml:
<property name="cancelDate" column="CANCELDATE" type="integer" generated="never" insert="false" update="false"/>

In my POJO I have a basic getter/setter of type Integer.
/**
* @return Returns the cancelDate.
*/
public Integer getCancelDate() {
return cancelDate;
}
/**
* @param cancelDate The cancelDate to set.
*/
public void setCancelDate(Integer cancelDate) {
this.cancelDate = cancelDate;
}


My question is does Hibernate automatically map Julian dates to standard Java Date objects? I'd like to simply set my type in the mapping file to date and change the POJO getter/setter to Date (instead of Integer).

_________________
Don


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 7:21 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
Not sure, but
think about it in terms of JDBC and your database.
if you created a java-jdbc test routine that opened up a ResultSet
and you called
rs.getDate("JDT");
and you JDT col was a number would it convert to java.sql.Date?
so, I think Julian date is milliseconds since January 1, 1970, 00:00:00 GMT ..right? if so, then it should work - since java.sql.Date has a constructor w/ milliseconds as argument.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.