Pandu Posted July 27, 2017 Share Posted July 27, 2017 I have a field which needs to be printed with the current time as Hours: Minutesfor example:Current time is Thu Jul 27 15:58:30 IST 2017I have to print 15:58I 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. Link to comment Share on other sites More sharing options...
darth_fader Posted July 27, 2017 Share Posted July 27, 2017 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now