• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Dynamic jasper reports: how to tell FastReportBuilder to respect timezone

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using this class

ar.com.fdvs.dj.domain.builders.FastReportBuilder

it is part of the the dynamic jasper package and allows creating jasper reports on-the-fly. The issue I have is that when I add a Timestamp column to my report, the time zone it uses for formatting is always EST.

Does anyone know how to accomplish this? Here is a snippet of code ...



I get this in the output: ... 12/06/2012 02:47:51 PM EST ...

Thanks in advance.
 
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What would "respecting a timezone" mean? I'm assuming that EST is the default time zone when the application runs, so what should cause the application to choose some other time zone?
 
Joe Simone
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:What would "respecting a timezone" mean? I'm assuming that EST is the default time zone when the application runs, so what should cause the application to choose some other time zone?



Sorry if I was not clear. The code does make use of the timezone defaulted to EST. I just want to be able to pass in and change the timezone accordingly. For example if someone from the west coast runs the report I would like the date to be formatted for PST (his local zone) instead of the default EST.

I've spent most of the day trying to google an example of how this would be done.

Thanks in advance.
 
Paul Clapham
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That would involve knowing how the report was run. If the person from the west coast ran the report on their own computer, then the default time zone would be their time zone and you wouldn't be asking the question. So I have to conclude that somehow the person from the west coast is running the report somehow on some other computer.
 
Joe Simone
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
True.

The reports are all run on our east coast servers, hence the default JVM timezone of EST. However, the customer's data maybe from another timezone - the one they are located in. The code that gets called for the jasper csv export has as one of its invocation parameter the timezone, but we have no place to set it so dynamic jasper FastReportBuilder can make use of it.

Therefore, I am stuck.

Thanks in advance.
 
Paul Clapham
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Simone wrote:The code that gets called for the jasper csv export has as one of its invocation parameter the timezone, but we have no place to set it so dynamic jasper FastReportBuilder can make use of it.



So there are two problems (I think).

(1) You need to fix that code so that you do have a place to set the time zone.

(2) You need some way of deciding which time zone to set, once (1) is fixed.
 
Joe Simone
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I tried setting timezone in the jasperPrint object thusly



and I still get the following in the CSV export ...

TIME ZONE SET TO ...US/Pacific
... ,12/06/2012 05:55:44 PM EST, ...

Not much progress today!

Thanks in advance.
 
Joe Simone
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This jasper forum comments seems to indicate this was recently addressed and fixed:

jasper community issue 4616
 
Joe Simone
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public static final String PROPERTY_TIME_ZONE = "net.sf.jasperreports.jdbc.time.zone"

How to set this property and where is now the question
 
Joe Simone
Greenhorn
Posts: 25
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I updated both DynamicJasper to 4.0.3 and jasper reports to 4.7.1 and tried to set the time zone 4 places in the code below. Still fails to set the timezone correctly.



Results we get are still wrong. Note the EST in the formatted date.

 
Joe Simone
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the solution to the problem. We must get the jasper print object to respect timezone and setting the timezone id was not having the expected results.



Now, by passing in a parameter map indicating the new timezone to override the default JVM timezone, we are able to get the JasperPrint object to respect the timezone.

This was tested with Dynamic Jasper 4.0.3 and Jasper reports version 5.0.0. I don't know if this functionality is broken in older versions of these jars so your results may vary.
 
Paul Clapham
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the follow-up, Joe!

 
reply
    Bookmark Topic Watch Topic
  • New Topic