Class TimeDurationFormatter
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.TimeDurationFormatter
-
public class TimeDurationFormatter extends java.lang.ObjectFormat 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 TimeDurationFormatterforLogging()Default formatter suitable for logging (ASCII-only)java.lang.Stringformat(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., specify2to switch to 'days' when the elapsed time is two or more days.allowNonAscii- set totrueif 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
-
-