public void testTime() throws Exception
{
cleanDateTimeTimestampTable();
// insert new DateTest object to db
DateTimeTimestampType dateTimeTimestamp = new DateTimeTimestampType();
Date now = new Date();
dateTimeTimestamp.setDateValue(now);
dateTimeTimestamp.setTimeValue(now);
dateTimeTimestamp.setTimestampValue(now);
dateTimeTimestamp.save();
// reload dateTest from db
DateTimeTimestampType loaded = DateTimeTimestampTypePeer.retrieveByPK(
dateTimeTimestamp.getPrimaryKey());
// calculate expected value
Date expected;
// if (adapter instanceof DBOracle)
// {
// expected = new Date(now.getTime() / 1000L * 1000L);
// }
// else
{
Calendar calendar = new GregorianCalendar();
calendar.setTime(now);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.MONTH, Calendar.JANUARY);
calendar.set(Calendar.YEAR, 1970);
calendar.set(Calendar.MILLISECOND, 0);
expected = calendar.getTime();
}
// verify
long loadedTimestampRounded
= loaded.getTimeValue().getTime() / 1000L * 1000L;
assertEquals(expected, new Date(loadedTimestampRounded));
}