Package com.jeff_media.jefflib
Class TimeUtils
java.lang.Object
com.jeff_media.jefflib.TimeUtils
Time related methods, like measuring time and converting nanoseconds to milliseconds, etc.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
dateToString
(long unix) Converts a Unix Timestamp to a Stringstatic long
endTimings
(String identifier) Ends the time measurement and prints out the duration in human readable millisecondsstatic long
endTimings
(String identifier, boolean sendMessage) Ends the time measurement, and optionally prints out the duration in human readable millisecondsstatic long
endTimings
(String identifier, Plugin plugin, boolean sendMessage) Ends the time measurement and optionally prints out the duration in human readable millisecondsstatic String
formatNanoseconds
(long nanoSeconds) Formats nanoseconds to a human readable format in milliseconds with 4 decimal placesstatic double
milliSecondsToTickPercentage
(long milliSeconds) Converts an amount of milliseconds to tick percentage.static long
nanoSecondsToMilliSeconds
(long nanoSeconds) Converts nanoseconds to millisecondsstatic double
nanoSecondsToMilliSecondsDouble
(long nanoSeconds) Converts nanoseconds to milliseconds, returning a double valuestatic String
secondsToDDHHMMSS
(long seconds) Converts seconds to Days, Hours, Minutes, Secondsstatic String
secondsToHHMMSS
(long seconds) Converts seconds to Hours, Minutes, Secondsstatic void
startTimings
(String identifier) Starts to record the time, using a String identifier, to be used in conjunction withendTimings(String)
-
Field Details
-
MILLISECONDS_PER_TICK
- See Also:
-
-
Constructor Details
-
TimeUtils
public TimeUtils()
-
-
Method Details
-
nanoSecondsToMilliSeconds
Converts nanoseconds to milliseconds- Parameters:
nanoSeconds
- duration in nanoseconds- Returns:
- duration in milliseconds
-
milliSecondsToTickPercentage
Converts an amount of milliseconds to tick percentage. E.g. 50 will return 100 and 25 will return 50- Parameters:
milliSeconds
- milliseconds- Returns:
- percentage of tick
-
formatNanoseconds
Formats nanoseconds to a human readable format in milliseconds with 4 decimal places- Parameters:
nanoSeconds
- Duration in nanoseconds
-
nanoSecondsToMilliSecondsDouble
Converts nanoseconds to milliseconds, returning a double value- Parameters:
nanoSeconds
- duration in nanoseconds- Returns:
- duration in milliseconds
-
startTimings
Starts to record the time, using a String identifier, to be used in conjunction withendTimings(String)
- Parameters:
identifier
- Name of the task to be measured
-
endTimings
Ends the time measurement and prints out the duration in human readable milliseconds- Parameters:
identifier
- Name of the task to be measured- Returns:
- duration the task took in nanoseconds
-
endTimings
Ends the time measurement, and optionally prints out the duration in human readable milliseconds- Parameters:
identifier
- Name of the task to be measured- Returns:
- duration the task took in nanoseconds
-
endTimings
Ends the time measurement and optionally prints out the duration in human readable milliseconds- Parameters:
identifier
- Name of the mask to be measuredplugin
- Plugin of which Logger to usesendMessage
- Whether to send a message- Returns:
- Duration in nanoseconds
-
dateToString
Converts a Unix Timestamp to a String- Parameters:
unix
- A Unix timestamp- Returns:
- The resulted String
-
secondsToDDHHMMSS
Converts seconds to Days, Hours, Minutes, Seconds- Parameters:
seconds
- The given amount of seconds- Returns:
- The resulted String
-
secondsToHHMMSS
Converts seconds to Hours, Minutes, Seconds- Parameters:
seconds
- The given amount of seconds- Returns:
- The resulted String
-