// Effective time will be right after the last running instance.
 private String getEffectiveTime(
     Entity entity, String cluster, Collection<InstanceState> instances) throws FalconException {
   if (instances == null || instances.isEmpty()) {
     return SchemaHelper.formatDateUTC(DateUtil.now());
   } else {
     List<InstanceState> instanceList = new ArrayList(instances);
     Collections.sort(
         instanceList,
         new Comparator<InstanceState>() {
           @Override
           public int compare(InstanceState x, InstanceState y) {
             return (x.getInstance().getInstanceSequence() < y.getInstance().getInstanceSequence())
                 ? -1
                 : (x.getInstance().getInstanceSequence() == y.getInstance().getInstanceSequence()
                     ? 0
                     : 1);
           }
         });
     // Get the last element as the list is sorted in ascending order
     Date lastRunningInstanceTime =
         instanceList.get(instanceList.size() - 1).getInstance().getInstanceTime().toDate();
     Cluster clusterEntity = ConfigurationStore.get().get(EntityType.CLUSTER, cluster);
     // Offset the time by a few seconds, else nextStartTime will be same as the reference time.
     Date effectiveTime =
         EntityUtil.getNextStartTime(
             entity, clusterEntity, DateUtil.offsetTime(lastRunningInstanceTime, 10));
     return SchemaHelper.formatDateUTC(effectiveTime);
   }
 }