-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
290fb13
commit 1a0a23d
Showing
4 changed files
with
29 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
apps/opik-backend/src/main/java/com/comet/opik/utils/DurationUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.comet.opik.utils; | ||
|
||
import lombok.NonNull; | ||
import lombok.experimental.UtilityClass; | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
|
||
@UtilityClass | ||
public class DurationUtils { | ||
|
||
public static final Double TIME_UNIT = 1_000.0; | ||
|
||
public static Double getDurationInSeconds(@NonNull Instant startTime, Instant endTime) { | ||
if (endTime == null) { | ||
return null; | ||
} | ||
|
||
long micros = Duration.between(startTime, endTime).toNanos() / TIME_UNIT.longValue(); | ||
return micros / TIME_UNIT; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters