Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320365 - Excel emitter don't use reportContext timezone
Summary: Excel emitter don't use reportContext timezone
Status: VERIFIED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.5.2   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Wei Yan CLA
QA Contact: fengfu liu CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-20 05:11 EDT by jean.dat CLA
Modified: 2013-09-17 02:12 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jean.dat CLA 2010-07-20 05:11:46 EDT
- Create a blank report ;

- Insert a "Data" Object of type "Date Time" without databinding. Write "new Date();" for the javascript expression ;

- When invoking your report from the web viewer, configure a timezone with "__timezone" parameter. For instance, for me, "&__timezone=Europe/Paris" (GMT+2) ;

- My JVM uses UTC ; 

- When using frameset servlet, in my browser, i have the right date. For instance 19/07/2010 18:19 (pattern is dd/MM/yyyy HH:mm).  ;

- When exporting to excel, I obtain a UTC date. For instance : 19/07/2010 16:19 (same pattern) ;

- All others emitters are good. I get this issue only with excel.

It seems that in jar org.eclipse.birt.report.engine.emitter.prototype.excel.xxx.jar, file org.eclipse.birt.report.engine.emitter.excel.ExcelUtil, method #formatDate, when formatting date as a String with a SimpleDateFormat, you don't use any timezone. Maybe the issue is here.

public static String formatDate( Object data ) {
	SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH );
	Date date = getDate( data );
	if(date == null) {
		return null;
	}
	return  dateFormat.format( date );        
}

An ugly solution is to set the default TimeZone in your initialize script : com.ibm.icu.util.TimeZone.setDefault(reportContext.getTimeZone());
Comment 1 BiM Mising name CLA 2010-07-20 08:04:09 EDT
Create a blank report.
This report should contain the date into the footer.
Switch the TimeZone to an exotic one (for example: Pacific/Easter) via the viewer attributes (__timezone), via the designer (Preferences > Preview > Timezone) or via tha Java API (options.setOption("timezone", "Pacific/Easter").
Generate to any format (without XLS), look at the date.
Generate to the XLS format, look at the date.
Note : This problem should get around adding this line to initialize script of each report:
com.ibm.icu.util.TimeZone.setDefault(reportContext.getTimeZone());
Comment 2 Xiaoying Gu CLA 2010-07-27 03:13:46 EDT
(In reply to comment #1)
> Create a blank report.
> This report should contain the date into the footer.
> Switch the TimeZone to an exotic one (for example: Pacific/Easter) via the
> viewer attributes (__timezone), via the designer (Preferences > Preview >
> Timezone) or via tha Java API (options.setOption("timezone", "Pacific/Easter").
> Generate to any format (without XLS), look at the date.
> Generate to the XLS format, look at the date.
> Note : This problem should get around adding this line to initialize script of
> each report:
> com.ibm.icu.util.TimeZone.setDefault(reportContext.getTimeZone());

Which build were you using?

I can not reproduce this issue in 2.6.0 release build. 
My steps were:
1. Change timezone to GMT-8 (while my os default timezone is GMT+8)
2. New a blank report which contains new Date() at matserpage footer.
3. Webviewer preview -> export contents as excel

The date at page footer is correct as GMT-8.
Comment 3 BiM Mising name CLA 2010-07-27 03:54:17 EDT
> Which build were you using?
Like it's indicate into the description : 2.5.2 but it could be reproduce in 2.6.0.
> 
> I can not reproduce this issue in 2.6.0 release build. 
> My steps were:
> 1. Change timezone to GMT-8 (while my os default timezone is GMT+8)
> 2. New a blank report which contains new Date() at matserpage footer.
> 3. Webviewer preview -> export contents as excel
> 
> The date at page footer is correct as GMT-8.

I do further tests to identify exactly where the problem occurs :
 - Keep the steps 1 and 3
 - (1) Add a text with this content : <value-of>new Date()</value-of>
 - (2) Add a dynamic text with this content : new Date()
 - (3) Add a data (type : Date Time) with this expression : new Date()
 - (4) Add a data (type : Time) with tihs expression : new Date()

In all formats except XLS, only the text (1) and the data element in Date Time type (3) works. The dynamic text (2) and the data in Time format (4) shows the current system date time.

In XLS, there is also the data element in Date Time type (4) that doesn't work.
Comment 4 Xiaoying Gu CLA 2010-07-27 05:06:54 EDT
I can reproduce this issue in 2.6.1 now.
Comment 5 BiM Mising name CLA 2010-07-28 07:59:07 EDT
(In reply to comment #4)
> I can reproduce this issue in 2.6.1 now.

Good news !

I think there is a lack of consistency between each elements (data, text, dynamic text) and each generated format.

We also can see if you choice a language for your report, in some case, it will show July (english) and in other cases, it will show juillet (french). The problem is probably in the same part of the code.
Comment 6 Wei Yan CLA 2013-09-09 18:41:21 EDT
commit 99c1428176f7e5eb9d43dad67c9d49f9a3c7854c
Comment 7 Jesse Weinstein CLA 2013-09-09 20:44:19 EDT
Thanks for linking to the commit! (and for fixing this bug from back in 2010 :-) ) https://git.eclipse.org/c/birt/org.eclipse.birt.git/commit/?id=99c1428176f7e5eb9d43dad67c9d49f9a3c7854c
Comment 8 fengfu liu CLA 2013-09-17 02:12:28 EDT
Tested in v4.3.1-20130916