Class StringToDateConverter

  • All Implemented Interfaces:
    Converter<java.lang.String,​java.util.Date>, java.io.Serializable

    public class StringToDateConverter
    extends java.lang.Object
    implements Converter<java.lang.String,​java.util.Date>
    A converter that converts from Date to String and back. Uses the given locale and DateFormat for formatting and parsing.

    Leading and trailing white spaces are ignored when converting from a String.

    Override and overwrite getFormat(Locale) to use a different format.

    Since:
    8.0
    Author:
    Vaadin Ltd
    See Also:
    Serialized Form
    • Constructor Detail

      • StringToDateConverter

        public StringToDateConverter()
    • Method Detail

      • convertToModel

        public Result<java.util.Date> convertToModel​(java.lang.String value,
                                                     ValueContext context)
        Description copied from interface: Converter
        Converts the given value from model type to presentation type.

        A converter can optionally use locale to do the conversion.

        Specified by:
        convertToModel in interface Converter<java.lang.String,​java.util.Date>
        Parameters:
        value - The value to convert. Can be null
        context - The value context for the conversion.
        Returns:
        The converted value compatible with the source type
      • convertToPresentation

        public java.lang.String convertToPresentation​(java.util.Date value,
                                                      ValueContext context)
        Description copied from interface: Converter
        Converts the given value from presentation type to model type.

        A converter can optionally use locale to do the conversion.

        Specified by:
        convertToPresentation in interface Converter<java.lang.String,​java.util.Date>
        Parameters:
        value - The value to convert. Can be null
        context - The value context for the conversion.
        Returns:
        The converted value compatible with the source type