Right now HSSFCell.setCellValue(Calendar) just calls HSSFCell.setCellValue(Date) automatically converting the given time to the default timezone. This means that 20:00+03:00 and 20:00-03:00 will not be reported as 20:00 but as two different times none of them 20:00 (unless the default timezone happens to be -03:00 or +03:00).
Created attachment 17688 [details] Patch HSSFCell.setCellValue(Calendar) to use the calendar's timezone This patch changes HSSFCell.setCellValue(Calendar) to use the Calendar's timezone so both 20:00-03:00 and 20:00+03:00 are reported as 20:00.
This bug is annoying when POI is used on the server side, and there are clients using different time zones. Currently, there is a workaround, but it would be simple to fix that bug. Here is the workaround: long time=date.getTime(); TimeZone defaultTZ=TimeZone.getDefault(); TimeZone usedTZ= [get the timezone to use here] int offset=usedTZ.getOffset(time) - defaultTZ.getOffset(time); if (offset!=0){ date=new Date(time+offset); } cell.setCellValue(date);
Patch updated to match current HSSFDateUtils structure, and applied to svn trunk