Class TimeDurationFormatter
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.TimeDurationFormatter
-
public class TimeDurationFormatter extends java.lang.Object
Format a time duration as human-readable string, inspired byStopwatch.toString()
.
-
-
Constructor Summary
Constructors Constructor Description TimeDurationFormatter(java.util.Locale locale, int threshold, boolean allowNonAscii)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TimeDurationFormatter
forLogging()
Default formatter suitable for logging (ASCII-only)java.lang.String
format(long amount, java.util.concurrent.TimeUnit unit)
Format the specified duration
-
-
-
Constructor Detail
-
TimeDurationFormatter
public TimeDurationFormatter(java.util.Locale locale, int threshold, boolean allowNonAscii)
- Parameters:
locale
- locale for formatting (affects the decimal point)threshold
- integral value that needs to be exceeded to switch to a certain time unit for display (e.g., specify2
to switch to 'days' when the elapsed time is two or more days.allowNonAscii
- set totrue
if the display unit can use the non-ASCII "micro" Unicode character
-
-
Method Detail
-
forLogging
public static TimeDurationFormatter forLogging()
Default formatter suitable for logging (ASCII-only)
-
format
public java.lang.String format(long amount, java.util.concurrent.TimeUnit unit)
Format the specified duration- Parameters:
amount
- number of time unitsunit
- time unit
-
-