Here's a better alternative.
Code:
private Date m_dteInternalDate = null; // This is in milliseconds from the epoch, TZ agnositic.
private static final TimeZone m_tzUI = TimeZone.getTimeZone("GMT+5"); // Really this should be in the UI layer, and passed into methods in this class
private static final Calendar m_Cal = GregorianCalendar.getInstance(m_tzUI);
/* This is the mapped getter, used only by Hibernate */
public Date getInternalDate()
{
return m_dteInternalDate;
}
/* This is the mapped setter, used only by Hibernate */
public void setInternalDate(Date date)
{
m_dteInternalDate = date;
}
/* This is the getter in the interface, used by the API */
public Calendar getDate()
{
return cal.setTime(m_dteInternalDate).clone();
}
/* This is the setter in the interface, used by the API */
public void setDate(Calendar date)
{
m_dteInternalDate = date.getTime().clone();
}
Better still, you could try using a custom UserType.