Package com.linecorp.armeria.common.util
Class TextFormatter
java.lang.Object
com.linecorp.armeria.common.util.TextFormatter
public final class TextFormatter extends Object
A utility class to format things as a
String
with ease.-
Method Summary
Modifier and Type Method Description static void
appendElapsed(StringBuilder buf, long elapsedNanos)
Appends the human-readable representation of the duration given aselapsed
to the specifiedStringBuilder
.static void
appendElapsed(StringBuilder buf, long startTimeNanos, long endTimeNanos)
Appends the human-readable representation of the duration between the specifiedstartTimeNanos
andendTimeNanos
to the specifiedStringBuilder
.static void
appendElapsedAndSize(StringBuilder buf, long startTimeNanos, long endTimeNanos, long size)
A shortcut method that callsappendElapsed(StringBuilder, long, long)
andappendSize(StringBuilder, long)
, concatenated by", "
.static void
appendEpochMicros(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 void
appendEpochMillis(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 void
appendInetAddress(StringBuilder buf, InetAddress addr)
Formats the givenInetAddress
.static void
appendSize(StringBuilder buf, long size)
Appends the human-readable representation of the specified byte-unitsize
to the specifiedStringBuffer
.static void
appendSocketAddress(StringBuilder buf, SocketAddress addr)
Formats the givenSocketAddress
.static StringBuilder
elapsed(long elapsedNanos)
Creates a newStringBuilder
whose content is the human-readable representation of the duration given aselapsed
.static StringBuilder
elapsed(long startTimeNanos, long endTimeNanos)
Creates a newStringBuilder
whose content is the human-readable representation of the duration between the specifiedstartTimeNanos
andendTimeNanos
.static StringBuilder
elapsedAndSize(long startTimeNanos, long endTimeNanos, long size)
Similar toappendElapsedAndSize(StringBuilder, long, long, long)
except that this method creates a newStringBuilder
.static StringBuilder
epochMicros(long timeMicros)
Formats the given epoch time in microseconds to typical human-readable format "yyyy-MM-dd'T'HH:mm:ss.SSSX".static StringBuilder
epochMillis(long timeMillis)
Formats the given epoch time in milliseconds to typical human-readable format "yyyy-MM-dd'T'HH:mm:ss.SSSX".static StringBuilder
inetAddress(InetAddress addr)
Formats the givenInetAddress
.static StringBuilder
size(long size)
Creates a newStringBuilder
whose content is the human-readable representation of the byte-unitsize
.static StringBuilder
socketAddress(SocketAddress addr)
Formats the givenSocketAddress
.
-
Method Details
-
elapsed
Creates a newStringBuilder
whose content is the human-readable representation of the duration given aselapsed
. -
elapsed
Creates a newStringBuilder
whose content is the human-readable representation of the duration between the specifiedstartTimeNanos
andendTimeNanos
. -
appendElapsed
Appends the human-readable representation of the duration given aselapsed
to the specifiedStringBuilder
. -
appendElapsed
Appends the human-readable representation of the duration between the specifiedstartTimeNanos
andendTimeNanos
to the specifiedStringBuilder
. -
size
Creates a newStringBuilder
whose content is the human-readable representation of the byte-unitsize
. -
appendSize
Appends the human-readable representation of the specified byte-unitsize
to 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.
-