Bug 38641

Summary: [PATCH] Use the calendar's timezone in HSSFCell.setCellValue(Calendar)
Product: POI Reporter: Hack Kampbjorn <hak>
Component: HSSFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: Patch HSSFCell.setCellValue(Calendar) to use the calendar's timezone

Description Hack Kampbjorn 2006-02-14 14:32:45 UTC
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
Comment 1 Hack Kampbjorn 2006-02-14 14:36:02 UTC
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.
Comment 2 Laurent Poublan 2008-02-07 05:23:18 UTC
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);
Comment 3 Nick Burch 2008-02-07 08:53:46 UTC
Patch updated to match current HSSFDateUtils structure, and applied to svn trunk