Spec-Zone.ru › OpenJavaFX 8
javafx.util.converter

Class LocalDateStringConverter

java.lang.Object
  • javafx.util.StringConverter<LocalDate>
    • javafx.util.converter.LocalDateStringConverter


public class LocalDateStringConverter
extends StringConverter<LocalDate>

StringConverter implementation for LocalDate values.

Since:

JavaFX 8u40

See Also:

LocalTimeStringConverter, LocalDateTimeStringConverter

  • Constructor Summary

    Constructors
    Constructor and Description
    LocalDateStringConverter()
    Create a StringConverter for LocalDate values, using a default formatter and parser based on IsoChronology, FormatStyle.SHORT, and the user's Locale.
    LocalDateStringConverter(DateTimeFormatter formatter, DateTimeFormatter parser)
    Create a {#link StringConverter} for LocalDate values using the supplied formatter and parser.
    LocalDateStringConverter(FormatStyle dateStyle)
    Create a StringConverter for LocalDate values, using a default formatter and parser based on IsoChronology, the specified FormatStyle, and the user's Locale.
    LocalDateStringConverter(FormatStyle dateStyle, Locale locale, Chronology chronology)
    Create a StringConverter for LocalDate values using a default formatter and parser, which will be based on the supplied FormatStyle, Locale, and Chronology.
  • Method Summary

    All MethodsInstance MethodsConcrete Methods
    Modifier and Type Method and Description
    LocalDate fromString(String value)
    Converts the string provided into an object defined by the specific converter.
    String toString(LocalDate value)
    Converts the object provided into its string form.
    • Methods inherited from class java.lang.Object

      clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Detail

    • LocalDateStringConverter

      public LocalDateStringConverter()
      Create a StringConverter for LocalDate values, using a default formatter and parser based on IsoChronology, FormatStyle.SHORT, 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 leniently as expected in these locales.

    • LocalDateStringConverter

      public LocalDateStringConverter(FormatStyle dateStyle)
      Create a StringConverter for LocalDate values, using a default formatter and parser based on IsoChronology, the specified FormatStyle, and the user's Locale.

      Parameters:

      dateStyle - The FormatStyle that will be used by the default formatter and parser. If null then FormatStyle.SHORT will be used.

    • LocalDateStringConverter

      public LocalDateStringConverter(DateTimeFormatter formatter,
                                      DateTimeFormatter parser)
      Create a {#link StringConverter} for LocalDate values using the supplied 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 converter =
           DateTimeStringConverter.getLocalDateStringConverter(formatter, null);
      Note that the formatter and parser can be created to handle non-default Locale and Chronology as needed.

      Parameters:

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

    • LocalDateStringConverter

      public LocalDateStringConverter(FormatStyle dateStyle,
                                      Locale locale,
                                      Chronology chronology)
      Create a StringConverter for LocalDate values using a default formatter and parser, which will be based on the supplied FormatStyle, Locale, and Chronology.

      Parameters:

      dateStyle - The FormatStyle that will be used by the default formatter and parser. If null then FormatStyle.SHORT will be used.

  • Method Detail

    • fromString

      public LocalDate fromString(String value)
      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.

      Specified by:

      fromString in class StringConverter<LocalDate>

      Returns:

      an object representation of the string passed in.

    • toString

      public String toString(LocalDate value)
      Converts the object provided into its string form. Format of the returned string is defined by the specific converter.

      Specified by:

      toString in class StringConverter<LocalDate>

      Returns:

      a string representation of the object passed in.

© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API