mirror of
https://github.com/Fishwaldo/rundeck-api-java-client.git
synced 2025-07-07 13:38:23 +00:00
add methods to get the duration of an execution
This commit is contained in:
parent
48948d4c52
commit
2fbc82dedd
1 changed files with 23 additions and 0 deletions
|
@ -2,6 +2,7 @@ package org.rundeck.api.domain;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Represents a RunDeck execution, usually triggered by an API call. An execution could be a {@link RundeckJob}
|
||||
|
@ -34,6 +35,28 @@ public class RundeckExecution implements Serializable {
|
|||
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* @return the duration of the execution in milliseconds (or null if the duration is still running, or has been
|
||||
* aborted)
|
||||
*/
|
||||
public Long getDurationInMillis() {
|
||||
if (startedAt == null || endedAt == null) {
|
||||
return null;
|
||||
}
|
||||
return endedAt.getTime() - startedAt.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the duration of the execution in seconds (or null if the duration is still running, or has been aborted)
|
||||
*/
|
||||
public Long getDurationInSeconds() {
|
||||
Long durationInMillis = getDurationInMillis();
|
||||
if (durationInMillis == null) {
|
||||
return null;
|
||||
}
|
||||
return TimeUnit.MILLISECONDS.toSeconds(durationInMillis);
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue