Spring Batch Admin
  1. Spring Batch Admin
  2. BATCHADM-29

Dates are displayed in GMT instead of using the locale of the jvm

    Details

    • Type: Defect Defect
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.0
    • Fix Version/s: 1.0.0.M3
    • Component/s: Manager
    • Labels:
      None

      Description

      Version 1.0.0.CI-SNAPSHOT

      The timezone is hardcoded in the org.springframework.batch.admin.web.JobExecutionController class.
      In this class you see the following hardcoding of timezone to GMT all over the place...

      model.addAttribute(new JobExecutionInfo(jobExecution, TimeZone.getTimeZone("GMT")));

      I think it would be better to default the timezone to the users locale and make it possible to override it using a configuration setting. I'm in a GMT+10 timezone so displaying GMT times makes times appear way off and there is no indication on the web page that the time is displayed in GMT.

        Activity

        Hide
        Anthony Fryer added a comment -

        I had more of a look and think I can see why you set all Timezones to GMT. The duration in the JobExecutionInfo class is formatted using the same formatter as the startTime. The duration must use a GMT timezone formatter otherwise it will be displayed incorrectly (in my case being in a GMT+10 timezone, the duration was displayed as 10 hours more than it actually was using the default TimeZone). I added a new SimpleDateFormat to format the duration that is set to GMT timezone. The other formatters (dateFormat and timeFormat) should use the TimeZone passed in to the JobExecutionInfo constructor, which should be TimeZone.getDefault() unless configured otherwise. In fact it might be even better to remove TimeZone from the JobExecutionInfo constructor.

        Show
        Anthony Fryer added a comment - I had more of a look and think I can see why you set all Timezones to GMT. The duration in the JobExecutionInfo class is formatted using the same formatter as the startTime. The duration must use a GMT timezone formatter otherwise it will be displayed incorrectly (in my case being in a GMT+10 timezone, the duration was displayed as 10 hours more than it actually was using the default TimeZone). I added a new SimpleDateFormat to format the duration that is set to GMT timezone. The other formatters (dateFormat and timeFormat) should use the TimeZone passed in to the JobExecutionInfo constructor, which should be TimeZone.getDefault() unless configured otherwise. In fact it might be even better to remove TimeZone from the JobExecutionInfo constructor.
        Hide
        Dave Syer added a comment -

        Parameterized time zone in the controllers (defaults to VM locale). User can override by adding a bean definition called "userTimeZone" to servlet application context.

        Show
        Dave Syer added a comment - Parameterized time zone in the controllers (defaults to VM locale). User can override by adding a bean definition called "userTimeZone" to servlet application context.

          People

          • Assignee:
            Dave Syer
            Reporter:
            Anthony Fryer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1h
              1h
              Remaining:
              Remaining Estimate - 0d
              0d
              Logged:
              Time Spent - 1h
              1h