Bug 38641 - [PATCH] Use the calendar's timezone in HSSFCell.setCellValue(Calendar)
Summary: [PATCH] Use the calendar's timezone in HSSFCell.setCellValue(Calendar)
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-14 14:32 UTC by Hack Kampbjorn
Modified: 2008-02-07 08:53 UTC (History)
0 users



Attachments
Patch HSSFCell.setCellValue(Calendar) to use the calendar's timezone (4.83 KB, patch)
2006-02-14 14:36 UTC, Hack Kampbjorn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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
+03:00).
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);
  }
  cell.setCellValue(date);
Comment 3 Nick Burch 2008-02-07 08:53:46 UTC
Patch updated to match current HSSFDateUtils structure, and applied to svn trunk