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!
|