|
Brett, i thank for still looking into this.
If the timezone and the time components are so irrelevant, than please explain to my, why this fails:
@Test
public void update() throws SQLException {
this.entityManager.getTransaction().begin();
Foobar foobar = new Foobar();
Calendar hlp = Calendar.getInstance();
hlp.set(2013, 10-1, 15, 0, 0, 0);
foobar.setRefDate(hlp);
foobar.setTakenOn(Calendar.getInstance());
this.entityManager.persist(foobar);
this.entityManager.getTransaction().commit();
final int id = foobar.getId();
final DateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
Session session = entityManager.unwrap(Session.class);
session.doWork(new Work() {
@Override
public void execute(Connection connection) throws SQLException {
ResultSet rs = connection.createStatement().executeQuery("Select ref_date from foobars where id = " + id);
rs.next();
Date date = rs.getDate(1);
Assert.assertEquals("2013-10-15", sf.format(date));
System.out.println(date);
}
});
}
This only works if i set the calendar to hlp.set(2013, 10-1, 15, 2, 0, 0), otherwise the date ends up as 2013-10-14 in the database.
So i don't think we're done here.
|