Tuesday, March 10, 2009

Dealing with timestamps in BIRT reports

While trying to match date/time fields between a BIRT (Business Intelligence and Reporting Tools) report design file and a web service, I did not stumble upon any good tips on the BIRT Eclipse website, but eventually found this entry on the BIRT Exchange website: Convert String Date to Date Object in BIRT.

The example was not a perfect match for what I needed but threw me close enough to the solution.

The web service returns a long value corresponding to the time using the Java/C convention for milliseconds since Jan/1/1970 0:00:00 GMT”. Inside the BIRT data-set though, I could not find the “Timestamp” field available for other kinds of data-sources, such as the XML data-source. Returning a string representing the date and time is never a good strategy since it discards the time zone information.

The solution was to create a computed field with “Date Time” type, then use this expression derived from the article to convert the milliseconds value retrieved from the web service (originally named “Date”):

df = new Packages.java.util.Date();



The next step was to indicate the correct type for the new computed parameter “DateTime” in my chart:


No comments:

Post a Comment