Jump to content
We've recently updated our Privacy Statement, available here ×

How to manage timezone in jrxml?


Pandu

Recommended Posts

I have a field which needs to be  printed with the current time as Hours: Minutes

for example:

Current time is Thu Jul 27 15:58:30 IST 2017
I have to print 15:58

I have tried as 

image(8).png.da7a13d33691bbf55fb489e533c1b072.png.

It is printing what I need . But the problem is with timezone. 
MySystem timezone is in UTC.
I need to change it to CET/CEST. (Please don't suggest to change it system side. I strictly need to do it from Jasper )

How I can do that?
Can anyone please help me to understand how to implement this?

Thanks in advance.


 

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

Joda Time is the easiest way to do time zone manipulations on date time fields in Jasper Reports (at least until Java 8 is fully supported).


joda time download link:


http://joda-time.sourceforge.net/installation.html


For jasper-server, add the joda time jar file into:


YOUR-JASPER-DIRECTORY/WEB-INF/lib


You'll notice other jar files there as well. WIll require a server restart to take effect.


 


If you're just using IReport/Jasper Studio, you'll need to add the jar to the class path, something along the lines of


Tools-->Option-->Classpath-->Add JAR


 


 

The code reference will be something like; see the ref to the example field below? You'll probably be able to make a go of it after this example:


<textFieldExpression><![CDATA[new org.joda.time.DateTime($F{YOUR_DATE_FIELD}).withZone(org.joda.time.DateTimeZone.forID("UTC"))]]></textFieldExpression>

 

It may be easier to add this in through the expression editor in IReport/Jasper Studio.

 

let me know if you run into any issues

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...