I am migrating the jasperserver from 3.7 to jasperserver 6.0.1, now in new jasperserver i want the date format to be dd/mm/yyyy but by default the date format is yyyy-mm-dd. For this i changed the jasperserver_config.properties file at
apache-tomcat-7.0.65\webapps\jasperserver\WEB-INF\bundles\jasperserver_config.properties
i changed it to
# Used for parsing and formatting dates by server
date.format=dd/MM/yyyy
datetime.format=dd/MM/yyyy HH:mm:ss
time.format=HH:mm:ss
# Used for parsing and formatting dates by calendar component (UI).
# Pattern for date should match appropriated pattern from server properties.
# The format for calendar component can be combinations of the following:
# d - day of month (no leading zero)
# dd - day of month (two digit)
# o - day of year (no leading zeros)
# oo - day of year (three digit)
# D - day name short
# DD - day name long
# m - month of year (no leading zero)
# mm - month of year (two digit)
# M - month name short
# MM - month name long
# y - year (two digit)
# yy - year (four digit)
calendar.date.format=dd/mm/yyyy
calendar.datetime.format=dd/mm/yyyy HH:mm:ss
calendar.time.format=HH:mm:ss
It changed the date format but when I am going to schedule any report the date field is showing as invalid date(see below). Can some one help me in changing the date format that work correctly all over jasperserver
There is a bug with this up to version 6.10 of JasperReports Server, see bug report. I've had to use the solution #2 at the time being.
Solution #1
If possible, update to version 6.10.
Solution #2
This solution is a bit lengthy but works properly if both steps (changing the source, generating the optimized js file) are done:
You have to edit a js file for this to work properly. Use the pattern you need for your case.
in file
/opt/jasperreports-server-cp-5.5.0a/apache-tomcat/webapps/jasperserver/scripts/scheduler/model/job.js
you have to change this:row 5
from:
var UI_DATE_PATTERN = "YYYY-MM-DD HH:mm";
to:
var UI_DATE_PATTERN = "DD.MM.YYYY HH:mm";
row 766
from:
data.trigger.startDate = moment(data.trigger.startDate).format(SERVICE_DATE_PATTERN);
to:
data.trigger.startDate = moment(data.trigger.startDate,UI_DATE_PATTERN).format(SERVICE_DATE_PATTERN);
Optimized Java Script
NOTE: Because of the optimized Javascript files (which is not the one which is edited as far as I remember), keep in mind you might need to recreate the optimized js file - since the optimized one is the one which is used by JRS. This was the case in v 5.6.x at least:
- Create a working directory where you can copy JavaScript files and install and run the required scripts. In this example, the directory is called Working.
- Create a subdirectory for a copy of the JavaScript files from JasperReports Server. This directory is called
jssources
.Copy the following directories from the JasperReports Server directory,
<js-webapp>
, tojs-sources
:• Copy
<js-webapp>/scripts
tojs-sources/scripts
.• Copy
<js-webapp>/fusion
tojs-sources/fusion
(optional, Pro version only)- Back up your
js-sources
directory.- Create a
js-optimization-output
directory for the output of the optimization process.- Download and install
node.js
from http://nodejs.org/. Place thenodejs
folder directly in your Working folder.- Download
r.js
, a requirejs optimization file, from http://requirejs.org and place it directly in the Working folder.- Make your changes to the JavaScript files in
Working/js-sources
.Open a command line tool and run the commands to optimize the JavaScript. The following example is for Windows, it places the output in the Working/js-optimization-output folder:
% cd Working
% nodejs\node r.js -o js-sources\scripts\build.js appDir=js-sources\scripts baseUrl=. optimize=uglify2 dir=js-optimization-output
- Copy the optimized scripts from
js-optimization-output
to<webapp>/optimized-scripts
(where webapp is the location of your JRS)- Reload the web app in the app server to see the changes.
NOTE: Keep in mind to clear your browser cache if there are problems after doing all this.