ApplicationEvent next = usage.getEvents().get(i + 1); eventEndDate = next.getDate(); } else if (current.getState() == Lifecycle.DESTROYED) { eventEndDate = eventStartDate; } else { UsageStatistic statistic = new UsageStatistic(ApplicationTransformer.statusFromLifecycle(current.getState()), usage.getApplicationId(), usage.getApplicationId(), format(eventStartDate), format(eventEndDate), duration, usage.getMetadata()); log.trace("Adding application usage statistic to response for app {}: {}", usage.getApplicationId(), statistic); result.add(statistic);