On this page

FormattableUtils

@Deprecated public class org.apache.commons.lang3.text.FormattableUtils[source]

Deprecated: As of 3.6, use Apache Commons Text FormattableUtils.

Provides utilities for working with the Formattable interface.

The Formattable interface provides basic control over formatting when using a Formatter. It is primarily concerned with numeric precision and padding, and is not designed to allow generalized alternate formats.

Since:

3.0

Constructors

FormattableUtils()

FormattableUtils instances should NOT be constructed in standard programming.

public FormattableUtils()[source]

FormattableUtils instances should NOT be constructed in standard programming. Instead, the methods of the class should be invoked statically.

This constructor is public to permit tools that require a JavaBean instance to operate.

Methods

append(CharSequence, Formatter, int, int, int)

Handles the common Formattable operations of truncate-pad-append, with no ellipsis on precision overflow, and padding width underflow with spaces.

append(CharSequence, Formatter, int, int, int, char)

Handles the common Formattable operations of truncate-pad-append, with no ellipsis on precision overflow.

append(CharSequence, Formatter, int, int, int, char, CharSequence)

Handles the common Formattable operations of truncate-pad-append.

append(CharSequence, Formatter, int, int, int, CharSequence)

Handles the common Formattable operations of truncate-pad-append, padding width underflow with spaces.

toString(Formattable)

Gets the default formatted representation of the specified Formattable.

public static Formatter append(CharSequence seq, Formatter formatter, int flags, int width, int precision)[source]

Handles the common Formattable operations of truncate-pad-append, with no ellipsis on precision overflow, and padding width underflow with spaces.

Parameters:
  • seq – The string to handle, not null.

  • formatter – The destination formatter, not null.

  • flags – The flags for formatting, see Formattable.

  • width – The width of the output, see Formattable.

  • precision – The precision of the output, see Formattable.

Returns:

The formatter instance, not null.

public static Formatter append(CharSequence seq, Formatter formatter, int flags, int width, int precision, char padChar)[source]

Handles the common Formattable operations of truncate-pad-append, with no ellipsis on precision overflow.

Parameters:
  • seq – The string to handle, not null.

  • formatter – The destination formatter, not null.

  • flags – The flags for formatting, see Formattable.

  • width – The width of the output, see Formattable.

  • precision – The precision of the output, see Formattable.

  • padChar – The pad character to use.

Returns:

The formatter instance, not null.

public static Formatter append(CharSequence seq, Formatter formatter, int flags, int width, int precision, char padChar, CharSequence ellipsis)[source]

Handles the common Formattable operations of truncate-pad-append.

Parameters:
  • seq – The string to handle, not null.

  • formatter – The destination formatter, not null.

  • flags – The flags for formatting, see Formattable.

  • width – The width of the output, see Formattable.

  • precision – The precision of the output, see Formattable.

  • padChar – The pad character to use.

  • ellipsis – The ellipsis to use when precision dictates truncation, null or empty causes a hard truncation.

Returns:

The formatter instance, not null.

public static Formatter append(CharSequence seq, Formatter formatter, int flags, int width, int precision, CharSequence ellipsis)[source]

Handles the common Formattable operations of truncate-pad-append, padding width underflow with spaces.

Parameters:
  • seq – The string to handle, not null

  • formatter – The destination formatter, not null.

  • flags – The flags for formatting, see Formattable.

  • width – The width of the output, see Formattable.

  • precision – The precision of the output, see Formattable.

  • ellipsis – The ellipsis to use when precision dictates truncation, null or empty causes a hard truncation.

Returns:

The formatter instance, not null.

public static String toString(Formattable formattable)[source]

Gets the default formatted representation of the specified Formattable.

Parameters:

formattable – The instance to convert to a string, not null.

Returns:

The resulting string, not null.