Package org.apache.camel.util
Class TimeUtils
java.lang.Object
org.apache.camel.util.TimeUtils
Time utils.
-
Method Summary
Modifier and TypeMethodDescriptionstatic longelapsedMillisSince(long start) Elapsed time using milliseconds since epoch.static booleanisPositive(Duration dur) static StringprintAge(long age) Prints the ago in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, as seen on Kubernetes etc.static StringprintDuration(long uptime) Prints the duration in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, etc.static StringprintDuration(long uptime, boolean precise) Prints the duration in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, etc.static StringprintDuration(Duration uptime) Prints the duration in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, etc.static StringprintDuration(Duration uptime, boolean precise) Prints the duration in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, etc.static StringprintSince(long time) Prints the since ago in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, as seen on Kubernetes etc.static DurationtoDuration(String source) Converts to duration.static longtoMilliSeconds(String source) Converts to milliseconds.
-
Method Details
-
isPositive
-
printSince
Prints the since ago in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, as seen on Kubernetes etc.- Parameters:
time- time of the event (millis since epoch)- Returns:
- ago in human-readable since the given time.
-
printAge
Prints the ago in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, as seen on Kubernetes etc.- Parameters:
age- age in millis- Returns:
- ago in human-readable.
-
printDuration
Prints the duration in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, etc.- Parameters:
uptime- the uptime in millis- Returns:
- the time used for displaying on screen or in logs
-
printDuration
Prints the duration in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, etc.- Parameters:
uptime- the uptime in millisprecise- whether to be precise and include more details- Returns:
- the time used for displaying on screen or in logs
-
printDuration
Prints the duration in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, etc.- Parameters:
uptime- the uptime in millis- Returns:
- the time used for displaying on screen or in logs
-
printDuration
Prints the duration in a human-readable format as 9s, 27m44s, 3h12m, 3d8h, etc.- Parameters:
uptime- the uptime in millisprecise- whether to be precise and include more details- Returns:
- the time used for displaying on screen or in logs
-
toDuration
Converts to duration.- Parameters:
source- duration which can be in text format such as 15s
-
toMilliSeconds
Converts to milliseconds.- Parameters:
source- duration which can be in text format such as 15s- Returns:
- time in millis, will return 0 if the input is null or empty
-
elapsedMillisSince
Elapsed time using milliseconds since epoch.- Parameters:
start- the timestamp in milliseconds since epoch- Returns:
- the elapsed time in milliseconds
-