Bug 320365 Excel emitter don't use reportContext timezone
- 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());
engine/org.eclipse.birt.report.engine.emitter.prototype.excel/src/org/eclipse/birt/report/engine/emitter/excel/ExcelUtil.java
import org.eclipse.birt.report.engine.css.engine.value.FloatValue;
import org.eclipse.birt.report.engine.emitter.excel.layout.ExcelLayoutEngine;
import org.eclipse.birt.report.engine.ir.DimensionType;
import com.ibm.icu.text.NuFormat;
import com.ibm.icu.text.SimpleDateFormat;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.Currency;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale;
public class ExcelUtil
{
	public static final int SHEETNAME_LENGTH = 31;
	private static final char EXCEL_DECIMAL_SEPARATOR = '.';
	public final static int maxCellTextLength = 32767;
	private final static String scicPattern = "0*.*0*E0*";
	private static final double SECONDS_PER_DAY = 86400.0;
	private static final double SECONDS_PER_MINUTE = 60.0;
	private static final double SECONDS_PER_HOUR = 3600.0;
	protected static final BigDecimal MAX_DOUBLE = new BigDecimal(
			Double.MAX_VALUE );
	protected static final BigDecimal MIN_DOUBLE = MAX_DOUBLE.negate( )
			.subtract( BigDecimal.ONE );
	protected static final BigDecimal MIN_POSITIVE_DECIMAL_NUMBER = new BigDecimal(
			"0.000000000000001" );
	protected static final BigDecimal MAX_POSITIVE_DECIMAL_NUMBER = new BigDecimal(
			10e15 ).subtract( MIN_POSITIVE_DECIMAL_NUMBER );
	protected static final BigDecimal MIN_NEGATIVE_DECIMAL_NUMBER = new BigDecimal(
			-10e14 ).add( new BigDecimal( "0.000000000000001" ) );
	protected static final BigDecimal MAX_NEGATIVE_DECIMAL_NUMBER = MIN_POSITIVE_DECIMAL_NUMBER
			.negate( );