At
org.dbunit.dataset.excel.XlsTable.java,
the code below causes dates to be wrong parsed from XLS files.
The way it is, Jan 10, 2009 00:00, in GMT+3, is valued as Jan 09, 2009, 21:00.
To avoid the bug, one can pass
-Duser.timezone=GMT
to the TestRunner, so offset is hard forced to be zero, and date is not changed.
protected Object getDateValue(HSSFCell cell)
{
logger.debug("getDateValue(cell={}) - start", cell);
double numericValue = cell.getNumericCellValue();
Date date = HSSFDateUtil.getJavaDate(numericValue); // at this point, date is OK
// This code subtracts "default" offset from date parsed from XLS, causing the bug
// Add the timezone offset again because it was subtracted automatically by Apache-POI (we need UTC)
long tzOffset = TimeZone.getDefault().getOffset(date.getTime());
date = new Date(date.getTime() + tzOffset);
return new Long(date.getTime());
}
Thanks,
Fábio.
Committed both of the above.
Related
Bugs:
#371Commit: [2bc788]