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
.
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.
1 Answer:
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: