changing date format/pattern in input control

Hi there,

I was wondering if it is possible to change the format/pattern of the Date displayed in the Input Controls?

Currently, when i select a date (using the Calendar), the date field is displayed as '12-01-2009', in my country, it is custom to use a dd-MM-yyyy pattern: '01-12-2009'. However, the input control does not accept this.  Can i change this? and how :)

note: changing the pattern on the local resource does not seem to work

sjongenelen's picture
Joined: Nov 9 2009 - 1:05am
Last seen: 13 years 10 months ago

3 Answers:

Hey

I just figured this out myself recently.
Go to your folder corresponding to the following (depending of course of your jasper server version and installation path):

C:\\Program Files\\Jaspersoft\\jasperserver-3.5.0\\apache-tomcat\\webapps\\jasperserver\\WEB-INF\\bundles

and open up jasperserver_config.properties in a text editor. Simply swop around the month parts with the day parts, e.g.

date.format=dd-MM-yyyy
datetime.format=dd-MM-yyyy HH:mm
calendar.date.format=%d-%m-%Y
calendar.datetime.format=%d-%m-%Y %H:%M

After restarting you jasper server, your input control should now expect entries of dd-MM-yyyy when typing in the date manually, and also if you use the calendar control to select a date this will display as dd-MM-yyyy as well.

 

msn's picture
msn
218
Joined: Dec 23 2009 - 2:00am
Last seen: 13 years 9 months ago

thank you for your quick and precize reply; worked like a charm!

 

one question though; i presume the Date input field is passed as a Date object (java.util.date?) to the JRXML? if so, there will be no problem with existing report units :)

sjongenelen's picture
Joined: Nov 9 2009 - 1:05am
Last seen: 13 years 10 months ago
Yes, it will still be passed to your report as a Date object. You only change the input format, as the system needs to know how to parse the string to make the date object.

Of course the change will apply to all reports using date input controls on the same jasper server, but you do not have to change how your reports use the date objects. It is only how the user types the input.

It does not affect converting the Date object back to string either. You still need to do this yourself, e.g. using SimpleDateFormat.
msn's picture
msn
218
Joined: Dec 23 2009 - 2:00am
Last seen: 13 years 9 months ago
Feedback