APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.util.converter

public Class LocalDateTimeStringConverter

extends StringConverter<LocalDateTime>
Class Inheritance
Imports
java.time.LocalDate, .LocalTime, .LocalDateTime, java.time.chrono.Chronology, .IsoChronology, java.time.format.DateTimeFormatter, .DateTimeFormatterBuilder, .DecimalStyle, .FormatStyle, java.time.temporal.Temporal, .TemporalAccessor, java.util.Locale, javafx.util.StringConverter

StringConverter implementation for LocalDateTime values.

Since
JavaFX 8u40
See Also
LocalDateStringConverter, LocalTimeStringConverter

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv LocalDateTimeStringConverter.LdtConverter<LocalDateTime>

Constructor Summary

AccessConstructor and Description
public
LocalDateTimeStringConverter()

Create a StringConverter for LocalDateTime values, using a default formatter and parser based on IsoChronology, FormatStyle#SHORT for both date and time, and the user's Locale.

public
LocalDateTimeStringConverter(FormatStyle
The FormatStyle that will be used by the default formatter and parser for the date. If null then FormatStyle#SHORT will be used.
dateStyle
,
FormatStyle
The FormatStyle that will be used by the default formatter and parser for the time. If null then FormatStyle#SHORT will be used.
timeStyle
)

Create a StringConverter for LocalDateTime values, using a default formatter and parser based on IsoChronology, the specified FormatStyle values for date and time, and the user's Locale.

public
LocalDateTimeStringConverter(DateTimeFormatter
An instance of DateTimeFormatter which will be used for formatting by the toString() method. If null then a default formatter will be used.
formatter
,
DateTimeFormatter
An instance of DateTimeFormatter which will be used for parsing by the fromString() method. This can be identical to formatter. If null then formatter will be used, and if that is also null, then a default parser will be used.
parser
)

Create a StringConverter for LocalDateTime values using the supplied formatter and parser.

public
LocalDateTimeStringConverter(FormatStyle
The FormatStyle that will be used by the default formatter and parser for the date. If null then FormatStyle#SHORT will be used.
dateStyle
,
FormatStyle
The FormatStyle that will be used by the default formatter and parser for the time. If null then FormatStyle#SHORT will be used.
timeStyle
,
Locale
The Locale that will be used by the default formatter and parser. If null then Locale.getDefault(Locale.Category.FORMAT) will be used.
locale
,
Chronology
The Chronology that will be used by the default formatter and parser. If null then IsoChronology#INSTANCE will be used.
chronology
)

Create a StringConverter for LocalDateTime values using a default formatter and parser, which will be based on the supplied FormatStyles, Locale, and Chronology.

Method Summary

Modifier and TypeMethod and Description
public LocalDateTime
fromString(String value)

Implements abstract javafx.util.StringConverter.fromString.

Converts the string provided into an object defined by the specific converter.

public String
toString(LocalDateTime value)

Implements abstract javafx.util.StringConverter.toString.

Converts the object provided into its string form.

Field Detail

ldtConverterback to summary
pack-priv LocalDateTimeStringConverter.LdtConverter<LocalDateTime> ldtConverter

Constructor Detail

LocalDateTimeStringConverterback to summary
public LocalDateTimeStringConverter()

Create a StringConverter for LocalDateTime values, using a default formatter and parser based on IsoChronology, FormatStyle#SHORT for both date and time, and the user's Locale.

This converter ensures symmetry between the toString() and fromString() methods. Many of the default locale based patterns used by DateTimeFormatter will display only two digits for the year when formatting to a string. This would cause a value like 1955 to be displayed as 55, which in turn would be parsed back as 2055. This converter modifies two-digit year patterns to always use four digits. The input parsing is not affected, so two digit year values can still be parsed as expected in these locales.

LocalDateTimeStringConverterback to summary
public LocalDateTimeStringConverter(FormatStyle dateStyle, FormatStyle timeStyle)

Create a StringConverter for LocalDateTime values, using a default formatter and parser based on IsoChronology, the specified FormatStyle values for date and time, and the user's Locale.

Parameters
dateStyle:FormatStyle

The FormatStyle that will be used by the default formatter and parser for the date. If null then FormatStyle#SHORT will be used.

timeStyle:FormatStyle

The FormatStyle that will be used by the default formatter and parser for the time. If null then FormatStyle#SHORT will be used.

LocalDateTimeStringConverterback to summary
public LocalDateTimeStringConverter(DateTimeFormatter formatter, DateTimeFormatter parser)

Create a StringConverter for LocalDateTime values using the supplied formatter and parser.

For example, to use a fixed pattern for converting both ways:

String pattern = "yyyy-MM-dd HH:mm";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
StringConverter<LocalDateTime> converter =
    DateTimeStringConverter.getLocalDateTimeConverter(formatter, null);
Note that the formatter and parser can be created to handle non-default Locale and Chronology as needed.
Parameters
formatter:DateTimeFormatter

An instance of DateTimeFormatter which will be used for formatting by the toString() method. If null then a default formatter will be used.

parser:DateTimeFormatter

An instance of DateTimeFormatter which will be used for parsing by the fromString() method. This can be identical to formatter. If null then formatter will be used, and if that is also null, then a default parser will be used.

LocalDateTimeStringConverterback to summary
public LocalDateTimeStringConverter(FormatStyle dateStyle, FormatStyle timeStyle, Locale locale, Chronology chronology)

Create a StringConverter for LocalDateTime values using a default formatter and parser, which will be based on the supplied FormatStyles, Locale, and Chronology.

Parameters
dateStyle:FormatStyle

The FormatStyle that will be used by the default formatter and parser for the date. If null then FormatStyle#SHORT will be used.

timeStyle:FormatStyle

The FormatStyle that will be used by the default formatter and parser for the time. If null then FormatStyle#SHORT will be used.

locale:Locale

The Locale that will be used by the default formatter and parser. If null then Locale.getDefault(Locale.Category.FORMAT) will be used.

chronology:Chronology

The Chronology that will be used by the default formatter and parser. If null then IsoChronology#INSTANCE will be used.

Method Detail

fromStringback to summary
public LocalDateTime fromString(String value)

Implements abstract javafx.util.StringConverter.fromString.

Doc from javafx.util.StringConverter.fromString.

Converts the string provided into an object defined by the specific converter. Format of the string and type of the resulting object is defined by the specific converter.

Annotations
@Override
toStringback to summary
public String toString(LocalDateTime value)

Implements abstract javafx.util.StringConverter.toString.

Doc from javafx.util.StringConverter.toString.

Converts the object provided into its string form. Format of the returned string is defined by the specific converter.

Annotations
@Override
javafx.util.converter back to summary

pack-priv Class LocalDateTimeStringConverter.LdtConverter<T extends Temporal>

extends StringConverter<T extends Temporal>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv Chronology
pack-priv FormatStyle
pack-priv DateTimeFormatter
pack-priv Locale
pack-priv DateTimeFormatter
pack-priv FormatStyle
private Class<T>

Constructor Summary

AccessConstructor and Description
pack-priv
LdtConverter(Class<T> type, DateTimeFormatter formatter, DateTimeFormatter parser, FormatStyle dateStyle, FormatStyle timeStyle, Locale locale, Chronology chronology)

Method Summary

Modifier and TypeMethod and Description
private DateTimeFormatter
fixFourDigitYear(DateTimeFormatter formatter, FormatStyle dateStyle, FormatStyle timeStyle, Chronology chronology, Locale locale)

public T
fromString(String text)

Implements abstract javafx.util.StringConverter.fromString.

Converts the string provided into an object defined by the specific converter.

private DateTimeFormatter
getDefaultFormatter()

Return a default DateTimeFormatter instance to use for formatting and parsing in this StringConverter.

private DateTimeFormatter
public String
toString(T value)

Implements abstract javafx.util.StringConverter.toString.

Converts the object provided into its string form.

Field Detail

chronologyback to summary
pack-priv Chronology chronology
dateStyleback to summary
pack-priv FormatStyle dateStyle
formatterback to summary
pack-priv DateTimeFormatter formatter
localeback to summary
pack-priv Locale locale
parserback to summary
pack-priv DateTimeFormatter parser
timeStyleback to summary
pack-priv FormatStyle timeStyle
typeback to summary
private Class<T> type

Constructor Detail

LdtConverterback to summary
pack-priv LdtConverter(Class<T> type, DateTimeFormatter formatter, DateTimeFormatter parser, FormatStyle dateStyle, FormatStyle timeStyle, Locale locale, Chronology chronology)

Method Detail

fixFourDigitYearback to summary
private DateTimeFormatter fixFourDigitYear(DateTimeFormatter formatter, FormatStyle dateStyle, FormatStyle timeStyle, Chronology chronology, Locale locale)
fromStringback to summary
public T fromString(String text)

Implements abstract javafx.util.StringConverter.fromString.

Doc from javafx.util.StringConverter.fromString.

Converts the string provided into an object defined by the specific converter. Format of the string and type of the resulting object is defined by the specific converter.

Annotations
@SuppressWarnings:unchecked
@Override
getDefaultFormatterback to summary
private DateTimeFormatter getDefaultFormatter()

Return a default DateTimeFormatter instance to use for formatting and parsing in this StringConverter.

getDefaultParserback to summary
private DateTimeFormatter getDefaultParser()
toStringback to summary
public String toString(T value)

Implements abstract javafx.util.StringConverter.toString.

Doc from javafx.util.StringConverter.toString.

Converts the object provided into its string form. Format of the returned string is defined by the specific converter.

Annotations
@Override