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

# Class StringConverter<T>

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

Type Parameters:
  `T` - the type associated with the string conversions

Direct Known Subclasses:
  `BigDecimalStringConverter, BigIntegerStringConverter, BooleanStringConverter, ByteStringConverter, CharacterStringConverter, DateTimeStringConverter, DefaultStringConverter, DoubleStringConverter, FloatStringConverter, FormatStringConverter, IntegerStringConverter, LocalDateStringConverter, LocalDateTimeStringConverter, LocalTimeStringConverter, LongStringConverter, NumberAxis.DefaultFormatter, NumberStringConverter, ShortStringConverter`

public abstract class StringConverter<T> extends Object

Defines conversion behaviors between `String` and other types. Each subclass defines a formatting (type to string) and a parsing (string to type) behaviors. `StringConverter`s are usually used in controls for converting between the underlying model (represented by type `T`) and the visual `String` representation.

Subclasses are provided for primitive wrapper types, numbers, dates and times, and custom formats.

Implementation Note:
  JavaFX's implementations are immutable unless stated otherwise.
Since:
  JavaFX 2.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StringConverter()`
  Creates a default `StringConverter`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract T`
  `fromString(String string)`
  Converts a string to an object.
  `abstract 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

  - ### StringConverter

    public StringConverter()
    Creates a default `StringConverter`.

- ## Method Details

  - ### toString

    public abstract String toString(T object)
    Converts an object to a string form. The format of the returned string is defined by the specific converter.
    Parameters:
      `object` - the object of type `T` to convert
    Returns:
      a string representation of the object passed in

  - ### fromString

    public abstract T fromString(String string)
    Converts a string to an object. The parsing mechanism is defined by the specific converter.
    Parameters:
      `string` - the `String` to convert
    Returns:
      an object of type `T` created from the string passed in