How to assign Date parameters to Hibernate query for current timezone?

As it turned out Hibernate doesn’t convert dates to GMT automatically, it just cuts off time if you use query.setDate(), so if you pass “2009-01-16 12:13:14” it becomes “2009-01-16 00:00:00”.

To take time into consideration you need to use query.setTimestamp("date", dateObj) instead.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)