Community
Participate
Working Groups
- 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());
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());
(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.
> 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.
I can reproduce this issue in 2.6.1 now.
(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.
commit 99c1428176f7e5eb9d43dad67c9d49f9a3c7854c
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
Tested in v4.3.1-20130916