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 Details

    • elapsed

      public static StringBuilder elapsed​(long elapsedNanos)
      Creates a new StringBuilder whose content is the human-readable representation of the duration given as elapsed.
    • elapsed

      public static StringBuilder elapsed​(long startTimeNanos, long endTimeNanos)
      Creates a new StringBuilder whose content is the human-readable representation of the duration between the specified startTimeNanos and endTimeNanos.
    • appendElapsed

      public static void appendElapsed​(StringBuilder buf, long elapsedNanos)
      Appends the human-readable representation of the duration given as elapsed to the specified StringBuilder.
    • appendElapsed

      public static void appendElapsed​(StringBuilder buf, long startTimeNanos, long endTimeNanos)
      Appends the human-readable representation of the duration between the specified startTimeNanos and endTimeNanos to the specified StringBuilder.
    • size

      public static StringBuilder size​(long size)
      Creates a new StringBuilder whose content is the human-readable representation of the byte-unit size.
    • appendSize

      public static void appendSize​(StringBuilder buf, long size)
      Appends the human-readable representation of the specified byte-unit size to the specified StringBuffer.
    • elapsedAndSize

      public static StringBuilder elapsedAndSize​(long startTimeNanos, long endTimeNanos, long size)
      Similar to appendElapsedAndSize(StringBuilder, long, long, long) except that this method creates a new StringBuilder.
    • appendElapsedAndSize

      public static void appendElapsedAndSize​(StringBuilder buf, long startTimeNanos, long endTimeNanos, long size)
      A shortcut method that calls appendElapsed(StringBuilder, long, long) and appendSize(StringBuilder, long), concatenated by ", ".
    • epochMillis

      public 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".
      Parameters:
      timeMillis - epoch time in milliseconds
      Returns:
      the human readable string representation of the given epoch time
    • appendEpochMillis

      public 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 specified StringBuilder.
    • epochMicros

      public 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".
      Parameters:
      timeMicros - epoch time in microseconds
      Returns:
      the human readable string representation of the given epoch time
    • appendEpochMicros

      public 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 specified StringBuilder.
    • socketAddress

      public static StringBuilder socketAddress​(@Nullable SocketAddress addr)
      Formats the given SocketAddress. The difference from InetSocketAddress.toString() is that it does not format a host name if it's not available or it's same with the IP address.
    • appendSocketAddress

      public static void appendSocketAddress​(StringBuilder buf, @Nullable SocketAddress addr)
      Formats the given SocketAddress. The difference from InetSocketAddress.toString() is that it does not format a host name if it's not available or it's same with the IP address.
    • inetAddress

      public static StringBuilder inetAddress​(@Nullable InetAddress addr)
      Formats the given InetAddress. The difference from InetAddress.toString() is that it does not format a host name if it's not available or it's same with the IP address.
    • appendInetAddress

      public static void appendInetAddress​(StringBuilder buf, @Nullable InetAddress addr)
      Formats the given InetAddress. The difference from InetAddress.toString() is that it does not format a host name if it's not available or it's same with the IP address.