FormatStringConverter (JavaFX 28)
Description: declaration: module: javafx.base, package: javafx.util.converter, class: FormatStringConverter

# Class FormatStringConverter<T>

java.lang.Object
javafx.util.StringConverter<T>
javafx.util.converter.FormatStringConverter<T>

Type Parameters:
  `T` - the type converted to/from a string

public class FormatStringConverter<T> extends StringConverter<T>
A `StringConverter` implementation that can use a `Format` instance to convert arbitrary types to and from a string. Instances of this class are only immutable if the used `Format` is immutable.

Since:
  JavaFX 2.2

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FormatStringConverter(Format format)`
  Creates a `FormatStringConverter` for arbitrary types that uses the given `Format`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `T`
  `fromString(String string)`
  Converts a string to an object.
  `protected Format`
  `getFormat()`
  Returns the `Format` instance for formatting and parsing in this `FormatStringConverter`.
  `String`
  `toString(T object)`
  Converts an object to a string form.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### FormatStringConverter

    public FormatStringConverter(Format format)
    Creates a `FormatStringConverter` for arbitrary types that uses the given `Format`.
    Parameters:
      `format` - the formatter/parser that will be used by the `toString()` and `fromString()` methods. Must not be `null`.

- ## Method Details

  - ### getFormat

    protected Format getFormat()
    Returns the `Format` instance for formatting and parsing in this `FormatStringConverter`.
    Returns:
      the `Format` instance for formatting and parsing in this `FormatStringConverter`

  - ### fromString

    public T fromString(String string)
    Converts a string to an object. The parsing mechanism is defined by the specific converter. `null` and empty string are converted to `null`.
    Specified by:
      `fromString` in class `StringConverter<T>`
    Parameters:
      `string` - the `String` to convert
    Returns:
      an object of type `T` created from the string passed in

  - ### toString

    public String toString(T object)
    Converts an object to a string form. The format of the returned string is defined by the specific converter. `null` is converted to an empty string, otherwise the type's `toString` is used.
    Specified by:
      `toString` in class `StringConverter<T>`
    Parameters:
      `object` - the object of type `T` to convert
    Returns:
      a string representation of the object passed in