Class LocalDateStringConverter
StringConverter implementation for LocalDate values.- Since:
- JavaFX 8u40
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates aLocalDateStringConverterthat uses a formatter and parser based onIsoChronology,FormatStyle.SHORT, and the user'sLocale.LocalDateStringConverter(DateTimeFormatter formatter, DateTimeFormatter parser) Creates aLocalDateStringConverterthat uses the given formatter and parser.LocalDateStringConverter(FormatStyle dateStyle) Creates aLocalDateStringConverterthat uses a formatter and parser based onIsoChronology, the specifiedFormatStyle, and the user'sLocale.LocalDateStringConverter(FormatStyle dateStyle, Locale locale, Chronology chronology) Creates aLocalDateStringConverterthat uses a formatter and parser based on the givenFormatStyle,Locale, andChronology. -
Method Summary
-
Constructor Details
-
LocalDateStringConverter
public LocalDateStringConverter()Creates a
LocalDateStringConverterthat uses a formatter and parser based onIsoChronology,FormatStyle.SHORT, and the user'sLocale.This converter ensures symmetry between the
toString()andfromString()methods. Many of the default locale based patterns used byDateTimeFormatterwill 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 leniently as expected in these locales. -
LocalDateStringConverter
Creates aLocalDateStringConverterthat uses a formatter and parser based onIsoChronology, the specifiedFormatStyle, and the user'sLocale.- Parameters:
dateStyle- theFormatStylethat will be used by the formatter and parser. Ifnull,FormatStyle.SHORTwill be used.
-
LocalDateStringConverter
Creates aLocalDateStringConverterthat uses a formatter and parser based on the givenFormatStyle,Locale, andChronology.- Parameters:
dateStyle- theFormatStylethat will be used by the formatter and parser. Ifnull,FormatStyle.SHORTwill be used.locale- theLocalethat will be used by the formatter and parser. Ifnull, the user's locale will be used.chronology- theChronologythat will be used by the formatter and parser. Ifnull,IsoChronology.INSTANCEwill be used.
-
LocalDateStringConverter
Creates a
LocalDateStringConverterthat uses the given formatter and parser.For example, to use a fixed pattern for converting both ways:
String pattern = "yyyy-MM-dd"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern); StringConverter<LocalDate> converter = DateTimeStringConverter.getLocalDateStringConverter(formatter, null);Note that the formatter and parser can be created to handle non-default
LocaleandChronologyas needed.- Parameters:
formatter- the formatter that will be used by thetoString()method. Ifnull, a default formatter will be used.parser- the parser that will be used by thefromString()method. This can be identical to formatter. Ifnull,formatterwill be used, and if that is alsonull, a default parser will be used.
-
-
Method Details
-
fromString
-
toString
Converts an object to a string form. The format of the returned string is defined by the specific converter.nullis converted to an empty string, otherwise the type'stoStringis used.- Parameters:
value- the object of typeTto convert- Returns:
- a string representation of the object passed in
-