Jump to content
  • REPORT_TIME_ZONE not applied to SimpleDateFormat

    Assigned User lucianc
    CategoryFeature request
    ResolutionWon't Fix

    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:


    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!



    User Feedback

    Recommended Comments

    Changed Resolution from Open to Won't Fix

    Changed Status from New to Resolved

    Changed Assigned User from - to @User_306070

    new SimpleDateFormat(..) is a plain Java call. Intercepting such calls to automatically inject the report time zone (and locale) would be very difficult.Nowadays there's a better way to explicitly format dates in reports, namely the DATEFORMAT builtin function, which honours the report time zone (and locale). A call to that function would look something like DATEFORMAT($V{ReportDate}, "yyyy.MM.dd G 'at' HH:mm:ss z")Closing as Won't Fix.Regards,Lucian
    Link to comment
    Share on other sites

  • Create New...