-->
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: Oracle Date not working
PostPosted: Fri Aug 17, 2007 5:55 am 
Newbie

Joined: Fri Aug 17, 2007 5:45 am
Posts: 6
Hi,

I have a Oracle table that has a Date colum in the format 18/07/2007 13:21:26

I'm making a conversion from the jsp page to java.util.Date like this:


public static Date dateForHibernate(String date){
DateFormat format = new SimpleDateFormat("dd/MM/yyyy hh:mm");
try {
return new Date(format.parse(date).getTime());
} catch (ParseException e) {
log.error("date exception in conversion: " + e);
return new Date();
}
}


When I do the query through hibernate, the date seems to be properly passed:


public AuditOnline[] findByDate(final Date start, final Date end) throws DaoException {
log.info("findByDate");
log.info("Start date: " + start.toString());
log.info("Start end: " + end.toString());
Collection collection = (Collection) this.hibernateTemplate.execute(
new HibernateCallback() {
public Object doInHibernate(Session session){
Query query = session.createQuery(" from AuditOnline " +
" where timestamp >= ? " +
" and timestamp <= ? " +
" order by orden desc ");
query.setCacheable(true);
query.setDate(0, start);
query.setDate(1, end);
return query.list();
}
});
AuditOnline ret[] = convertToDTO( (List) collection );
return ret;
}



However the results from the query are wrong, as if I were passing different date to the ones I'm looking for.

Please assist. Thanks!


Top
 Profile  
 
 Post subject: query.setTimestamp
PostPosted: Fri Aug 17, 2007 7:39 am 
Newbie

Joined: Thu Aug 16, 2007 1:24 pm
Posts: 4
maybe query.setTimestamp will do the trick?


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.