Having set my preferred display timezone in the parameters (JRParameter.REPORT_TIME_ZONE) I find that any text field defined as a date with pattern is formatted correctly. However the same date formatted using (new SimpleDateFormat(pattern)).format(date) is not.
Here is an example snippet of .jrxml
Report Date as Date:
$V{ReportDate}
Report Date as Str:
(new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z")).format($V{ReportDate})
And an example of the output in my environment (CDT is the REPORT_TIME_ZONE while PDT is the Server timezone that ran the report):
Report Date as Date: 2013.06.30 AD at 16:11:12 CDT
Report Date as Str: 2013.06.30 AD at 14:11:12 PDT
It understandable why this would be the case but the SimpleDateFormat function is wonderfully useful in string concatenation. I have no idea how hard it would be to override to make use of the REPORT_TIME_ZONE rather than TimeZone.getDefault() but it sure would be nice!
Recommended Comments