Uploaded image for project: 'OpenIDM'
  1. OpenIDM
  2. OPENIDM-9947

DateUtil class does not support round-trip transformations of temporalConstraint intervals

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: OpenIDM 6.0.0
    • Fix Version/s: None
    • Component/s: Module - Scheduler
    • Story Points:
      3

      Description

      Work for OPENIDM-6712 seemed to introduce a deal of confusion around the supported formats for temporalConstraint durations. The following code will throw a DateTimeParseException:

      final String duration = "2018-01-09T17:00:00Z/2018-01-10T17:00:00Z";
      LocalDateTime start = dateUtil.getStartOfInterval(duration);
      DateUtil.getZonedDateTime(dateUtil.formatDateTime(start));

      In the code above, the duration string has the format produced by the UI. The only way to obtain the LocalDateTime corresponding to the duration start is via dateUtil#getStartOfInterval. However, when a simple trigger is scheduled with a startTime, the ScheduleConfig class will set the start time using:

      DateUtil.getZonedDateTime(startTimeString)

      The String produced by dateUtil#formatDateTime(LocalDateTime instance) will generate a DateTimeParseException. This means that the intuitive path to use the DateUtil class to generate startTimes for triggers enforcing temporal constraints will blow up when these jobs are scheduled. This previously worked because temporal constraints were enforced by cron triggers, which have a different parsing regimen. 

      Currently, triggers with startTimes only work when the startTime is generated by the millisecond instance format (e.g.

      Calendar.getInstance().getTimeInMillis()

      Using this knowledge, a work-around is the following code:

      final String duration = "2018-01-09T17:00:00Z/2018-01-10T17:00:00Z";
      LocalDateTime start = dateUtil.getStartOfInterval(duration);
      DateUtil.getZonedDateTime(dateUtil.formatDateTime(Date.from(start.atZone(ZoneId.systemDefault()).toInstant())));

       

        Attachments

          Activity

            People

            Assignee:
            brmiller Brendan Miller
            Reporter:
            dhogan Dirk Hogan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: