DateTimeZone databaseTimeZone = DateTimeZone.forID(getCurrentSession().createSQLQuery("select DBTIMEZONE from dual").uniqueResult().toString());
return new DateTime(getCurrentSession().createQuery("select current_timestamp() from Company").list().get(0), databaseTimeZone);
Another way is specific to the database platform you are using. This uses the standard Oracle method of "select SYSDATE from dual" to return back a timestamp which contains all of date, time, and timezone.
Timestamp timestamp = (Timestamp) getCurrentSession().createSQLQuery("select SYSDATE param from dual").addScalar("param", Hibernate.TIMESTAMP).uniqueResult();
return new DateTime(timestamp);
No comments
Post a Comment