I have a spring application which uses hibernate. The requirement is to persist and retrieve the timestamps in GMT. I have set the application timezone to GMT using context listener as below.
TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
While the application now persists the timestamps in GMT consistently, while retrieving the timestamps from hibernate layer are inconsistent. The timestamps are returned some times in PST (the server's timezone).
My data retrieval query is as below
Query q=entityManager.createQuery("SELECT DISTINCT f FROM foo as f WHERE f.ID=?1 AND f.ID2=?2 ORDER >BY ID DESC").setParameter(1, id1).setParameter(2, id2);
q.setFirstResult(skip).setMaxResults(top).getResultList();
Any ideas on solving this issue?