Package com.pnfsoftware.jeb.util.format
Class TimeFormatter
java.lang.Object
com.pnfsoftware.jeb.util.format.TimeFormatter
Utility methods to format timestamps and time deltas.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatDuration(long durationMs) Format a time duration as a human-readable string.static StringformatExecutionTime(long exectimeMs) Format an execution time as a human-readable string.static StringformatTimestamp(long unixTimestampMs) Format an epoch timestamp as a UTC string using the following format:static StringformatTimestamp(long unixTimestampMs, String timezone) Format an epoch timestamp as using the following format:static StringformatTimestampDelta(long deltaMs) Deprecated.static StringformatTimestampLocal(long unixTimestampMs) Format an epoch timestamp as a local, system specific date-and-time string.
-
Constructor Details
-
TimeFormatter
public TimeFormatter()
-
-
Method Details
-
formatTimestamp
Format an epoch timestamp as a UTC string using the following format:YYYY/MM/DD-hh:mm:ss
- Parameters:
unixTimestampMs- Unix epoch timestamp in milliseconds- Returns:
- the formatted UTC timestamp
-
formatTimestamp
Format an epoch timestamp as using the following format:YYYY/MM/DD-hh:mm:ss
- Parameters:
unixTimestampMs- Unix epoch timestamp in millisecondstimezone- time zone identifier accepted byTimeZone.getTimeZone(String)- Returns:
- the formatted timestamp in the requested time zone
-
formatTimestampLocal
Format an epoch timestamp as a local, system specific date-and-time string.- Parameters:
unixTimestampMs- Unix epoch timestamp in milliseconds- Returns:
- the formatted local timestamp
-
formatTimestampDelta
Deprecated.useformatDuration(long)instead -
formatDuration
Format a time duration as a human-readable string. The reported duration usess, m, h, dfor seconds, minutes, hours, and days.To display milliseconds, use
formatExecutionTime(long).- Parameters:
durationMs- duration in milliseconds; it may be negative- Returns:
- the formatted duration
-
formatExecutionTime
Format an execution time as a human-readable string. The reported duration usesms, s, m, h, dfor milliseconds, seconds, minutes, hours, and days.- Parameters:
exectimeMs- execution time in milliseconds; it may be negative- Returns:
- the formatted execution time
-
formatDuration(long)instead