Hi everyone,<br />
<br />
I try to take into account DST values for a timezone. I set it via __timezone in the web viewer.<br />
<br />
It's probably a java problem but maybe you have a solution. I don't see it.<br />
<br />
Why BIRT is not using the DST offset for a timezone when printing date in a table ?<br />
<br />
I created two Text to see how BIRT via ICU and via JDK is handling dates.<br />
<br />
I get this :<br />
TimeZone IBM: 'heure avancée d’Europe centrale', ID: 'Europe/Paris', offset: '3600000 ms', DST: '3600000 ms', DST ON: 'true', DST used: 'true'<br />
And this :<br />
TimeZone SUN: 'Heure d'été d'Europe centrale', ID: 'Europe/Paris', offset: '3600000 ms', DST: '3600000 ms', DST ON: 'true', DST used: 'true'<br />
<br />
Each one print the timezone meta-data (raw offset, dst offset, etc.) but in one case, i use java.util.TimeZone.getTimeZone(anID), and for the other I use com.ibm.icu.util.TimeZone.getTimeZone(anID).<br />
<br />
I get the timezone id from reportContext.getTimeZone().getID(); <br />
<br />
=== code with com.ibm.icu implementation ===<br />
<VALUE-OF><br />
importPackage(Packages.com.ibm.icu.util);<br />
<br />
var tz = reportContext.getTimeZone();<br />
var curdate = new com.ibm.icu.util.GregorianCalendar().getTime();<br />
<br />
var result = "";<br />
if(tz != null) {<br />
<br />
result = "TimeZone IBM: '" + tz.getDisplayName(true, com.ibm.icu.util.TimeZone.LONG) + "', ID: '" + tz.getID() + "', offset: '" + tz.getRawOffset() + " ms', DST: '" + tz.getDSTSavings() + " ms', DST ON: '" + tz.inDaylightTime(curdate) + "', DST used: '" + tz.useDaylightTime() + "'";<br />
}<br />
</VALUE-OF><br />
<br/><br />
=== code ===<br />
<br />
=== code with java.util implementation ===<br />
<VALUE-OF><br />
importPackage(Packages.java.util);<br />
<br />
var tz = java.util.TimeZone.getTimeZone(reportContext.getTimeZone().getID());<br />
<br />
var curdate = new java.util.GregorianCalendar().getTime();<br />
<br />
var result = "";<br />
if(tz != null) {<br />
<br />
result = "TimeZone SUN: '" + tz.getDisplayName(true, java.util.TimeZone.LONG) + "', ID: '" + tz.getID() + "', offset: '" + tz.getRawOffset() + " ms', DST: '" + tz.getDSTSavings() + " ms', DST ON: '" + tz.inDaylightTime(curdate) + "', DST used: '" + tz.useDaylightTime() + "'";<br />
}<br />
</VALUE-OF><br />
<br/><br />
=== code ===<br />
<br />
Each one print the same result except for the display name which is a little bit different depending on the timezone ID. We can see that both implementation (JDK and ICU) know that DST is on and has a value of 1 hour.<br />
<br />
But when printing a DateTime object from a dataset, it is always false (no DST offset). I try with both solution :<br />
- let birt manage (I just place a data binding in my table via Drag&Drop with a custom pattern via a style) ;<br />
- put a text with a javascript expression ;<br />
<br />
To have the right value, I need to do it myself adding DST offset manually to the date.<br />
<br />
=== code ===<br />
importPackage(Packages.java.utill);<br />
importPackage(Packages.java.text);<br />
<br />
ed = dataSetRow["departureDate"];<br />
<br />
gc = new java.util.GregorianCalendar();<br />
tz = java.util.TimeZone.getTimeZone(reportContext.getTimeZone().getID())<br />
gc.setTimeZone(tz);<br />
gc.setTimeInMillis(ed.getTime() + tz.getDSTSavings()); <<< HERE<br />
<br />
sdf = new java.text.SimpleDateFormat("d MMM HH:mm:ss", reportContext.getLocale());;<br />
sdf.setTimeZone(tz);<br />
<br />
sdf.format(gc.getTime());<br />
=== code ===<br />
<br />
I thought timezone issues were resolved since BIRT 2.3.2 :<br />
- <a class='bbc_url' href='
https://bugs.eclipse.org/bugs/show_bug.cgi?id=203035'>https://bugs.eclipse.org/bugs/show_bug.cgi?id=203035</a><br />
- <a class='bbc_url' href='
https://bugs.eclipse.org/bugs/show_bug.cgi?id=275098'>https://bugs.eclipse.org/bugs/show_bug.cgi?id=275098</a><br />
<br />
What am I doing wrong ?<br />
<br />
Thanks for any advice.<br />
<br />
Regards,<br />
<br />
Jean