Hi I have a server running in a particular timezone. I am wring a date to an oracle database using Hibernate and I want it to write the GMT Date.
into Oracle
My Code is as follows:
Code:
final Transaction t = s.beginTransaction();
TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
date d = Calendar.getInstance().getTime();
System.out.println(d);
Widget.setDate(d);
Widget.save();
t.commit();
Outputting the date field shows is as GMT e.g
14 Jun 2005 13:04:48 GMT
but when written to Oracle and SQL Statements shows it has been set to June 15 (my client is set to show dates as GMT)
The entry in my Hibernate Mapping is defined as thus
Code:
<property name="createddt" type="java.util.Date" insert="true" optimistic-lock="true" not-null="false" update="true" unique="false" lazy="false">
<column name="CREATED_DT" length="7" not-null="false" sql-type="DATE"/>
</property>
Hibernate seems to be ignoring my Timezone setting and writing it using the default Timezone of my machine (which is 13 hours ahead).
How can I get round this ?