Joe Simone

Greenhorn
+ Follow
since Feb 16, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Joe Simone

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.
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.

public static final String PROPERTY_TIME_ZONE = "net.sf.jasperreports.jdbc.time.zone"

How to set this property and where is now the question
This jasper forum comments seems to indicate this was recently addressed and fixed:

jasper community issue 4616

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.
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 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.
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.
Brilliant! That was it.

I simply changed the incorrect simple type in my schema from "normalizedString" to "string" and that fixed the problem.

God bless you Paul.

Thanks again,
Joe
I set up a test case to run through the scenario:

I can export to XML ok.
I can read the XML into a string ok.
When I parse the XML via DOM, the query node loses newlines.

Going into the parse I have this:





Coming out of the parse I have this:


15:28:35,083 INFO [STDOUT] select name from report where name like 'test'

Here is the code:

if (node.getNodeName().equals("query")) {
query = ((Element)node).getTextContent();
System.out.println(query);
}

Could the getTextContent() be the culprit and it so how do I fix the situation?

Thanks!
Ok, so I believed in error that I needed some additional markup in order to preserve the newlines. In actuality newlines are preserved by default without any additional measures -- as you have demonstrated.

In fact something along the line in my code is destroying the whitespace.

Investigating ...
Well here is what I am trying to accomplish.

I have a web page that connects to a datsource and lets one create a SQL query in a text area box. I click on a button and the query executes thereby returning a result set which is presented. All is fine.

Now, I would like to export this query to an XML schema defined XML export file. Once exported to an XML file, I would like to import any query file into the text area and run it or edit it. Its almost all fine except when I import the query, which can be very complex and have many lines, I lose the newlines!

So I would like to preserve the whitespace structure of the text that is being exported to and imported from an XML file.

I must be missing something somewhere.
I have xml that looks like this :



How do I parse the above using Xalan such that I can preserve the new lines?

Whatever I have tried has failed to keep each line of the query preserved. It all gets lumped together as "select name from person".

Thanks,
Joe
Ok.

I added the following code to the createDocumentFromString method


and now I only have 
 where the 
 used to be but the results
are the same. Xalan is losing the fact that newlines are specified. How can I get Xalan to respect the 
 ?
Oops, the newlines did not show on the post. Each line of the query tag ends with (and pound x d semicolon).

So the XML does have newlines in it.