Package com.linecorp.armeria.common.util
Class TextFormatter
java.lang.Object
com.linecorp.armeria.common.util.TextFormatter
A utility class to format things as a
String with ease.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendElapsed(StringBuilder buf, long elapsedNanos) Appends the human-readable representation of the duration given aselapsedto the specifiedStringBuilder.static voidappendElapsed(StringBuilder buf, long startTimeNanos, long endTimeNanos) Appends the human-readable representation of the duration between the specifiedstartTimeNanosandendTimeNanosto the specifiedStringBuilder.static voidappendElapsedAndSize(StringBuilder buf, long startTimeNanos, long endTimeNanos, long size) A shortcut method that callsappendElapsed(StringBuilder, long, long)andappendSize(StringBuilder, long), concatenated by", ".static voidappendEpochMicros(StringBuilder buf, long timeMicros) Formats the given epoch time in microseconds to typical human-readable format "yyyy-MM-dd'T'HH_mm:ss.SSSX" and appends it to the specifiedStringBuilder.static voidappendEpochMillis(StringBuilder buf, long timeMillis) Formats the given epoch time in milliseconds to typical human-readable format "yyyy-MM-dd'T'HH_mm:ss.SSSX" and appends it to the specifiedStringBuilder.static voidappendInetAddress(StringBuilder buf, @Nullable InetAddress addr) Formats the givenInetAddress.static voidappendSize(StringBuilder buf, long size) Appends the human-readable representation of the specified byte-unitsizeto the specifiedStringBuffer.static voidappendSocketAddress(StringBuilder buf, @Nullable SocketAddress addr) Formats the givenSocketAddress.static StringBuilderelapsed(long elapsedNanos) Deprecated.static StringBuilderelapsed(long startTimeNanos, long endTimeNanos) Creates a newStringBuilderwhose content is the human-readable representation of the duration between the specifiedstartTimeNanosandendTimeNanos.static StringBuilderCreates a newStringBuilderwhose content is the human-readable representation of the duration given aselapsed.static StringBuilderelapsedAndSize(long startTimeNanos, long endTimeNanos, long size) Similar toappendElapsedAndSize(StringBuilder, long, long, long)except that this method creates a newStringBuilder.static StringBuilderepochMicros(long timeMicros) Formats the given epoch time in microseconds to typical human-readable format "yyyy-MM-dd'T'HH:mm:ss.SSSX".static StringBuilderepochMillis(long timeMillis) Formats the given epoch time in milliseconds to typical human-readable format "yyyy-MM-dd'T'HH:mm:ss.SSSX".static StringBuilderinetAddress(@Nullable InetAddress addr) Formats the givenInetAddress.static StringBuildersize(long size) Creates a newStringBuilderwhose content is the human-readable representation of the byte-unitsize.static StringBuilderFormats the givenSocketAddress.
-
Method Details
-
elapsed
Creates a newStringBuilderwhose content is the human-readable representation of the duration given aselapsed. -
elapsed
Deprecated.Creates a newStringBuilderwhose content is the human-readable representation of the duration given aselapsed. -
elapsed
Creates a newStringBuilderwhose content is the human-readable representation of the duration between the specifiedstartTimeNanosandendTimeNanos. -
appendElapsed
Appends the human-readable representation of the duration given aselapsedto the specifiedStringBuilder. -
appendElapsed
Appends the human-readable representation of the duration between the specifiedstartTimeNanosandendTimeNanosto the specifiedStringBuilder. -
size
Creates a newStringBuilderwhose content is the human-readable representation of the byte-unitsize. -
appendSize
Appends the human-readable representation of the specified byte-unitsizeto the specifiedStringBuffer. -
elapsedAndSize
Similar toappendElapsedAndSize(StringBuilder, long, long, long)except that this method creates a newStringBuilder. -
appendElapsedAndSize
public static void appendElapsedAndSize(StringBuilder buf, long startTimeNanos, long endTimeNanos, long size) A shortcut method that callsappendElapsed(StringBuilder, long, long)andappendSize(StringBuilder, long), concatenated by", ". -
epochMillis
Formats the given epoch time in milliseconds to typical human-readable format "yyyy-MM-dd'T'HH:mm:ss.SSSX".- Parameters:
timeMillis- epoch time in milliseconds- Returns:
- the human readable string representation of the given epoch time
-
appendEpochMillis
Formats the given epoch time in milliseconds to typical human-readable format "yyyy-MM-dd'T'HH_mm:ss.SSSX" and appends it to the specifiedStringBuilder. -
epochMicros
Formats the given epoch time in microseconds to typical human-readable format "yyyy-MM-dd'T'HH:mm:ss.SSSX".- Parameters:
timeMicros- epoch time in microseconds- Returns:
- the human readable string representation of the given epoch time
-
appendEpochMicros
Formats the given epoch time in microseconds to typical human-readable format "yyyy-MM-dd'T'HH_mm:ss.SSSX" and appends it to the specifiedStringBuilder. -
socketAddress
Formats the givenSocketAddress. The difference fromInetSocketAddress.toString()is that it does not format a host name if it's not available or it's same with the IP address. -
appendSocketAddress
Formats the givenSocketAddress. The difference fromInetSocketAddress.toString()is that it does not format a host name if it's not available or it's same with the IP address. -
inetAddress
Formats the givenInetAddress. The difference fromInetAddress.toString()is that it does not format a host name if it's not available or it's same with the IP address. -
appendInetAddress
Formats the givenInetAddress. The difference fromInetAddress.toString()is that it does not format a host name if it's not available or it's same with the IP address.
-
elapsed(long, TimeUnit).