com.vaadin.flow.data.converter.
Class StringToDateConverter
All Implemented Interfaces:
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:
1.0
Author:
Vaadin Ltd
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToModel
(String value, ValueContext context) Converts the given value from presentation type to model type.
convertToPresentation
(Date value, ValueContext context) Converts the given value from model type to presentation type.
protected DateFormat
Returns the format used by
convertToPresentation(Date, ValueContext)
andconvertToModel(String, ValueContext)
.
-
Constructor Details
-
StringToDateConverter
public StringToDateConverter()
-
-
Method Details
-
getFormat
Returns the format used by
convertToPresentation(Date, ValueContext)
andconvertToModel(String, ValueContext)
.Parameters:
locale
- The locale to useReturns:
A DateFormat instance
-
convertToModel
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:
convertToModel
in interfaceConverter<String,
Date> Parameters:
value
- The value to convert. Can be nullcontext
- The value context for the conversion.Returns:
The converted value compatible with the source type
-
convertToPresentation
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:
convertToPresentation
in interfaceConverter<String,
Date> Parameters:
value
- The value to convert. Can be nullcontext
- The value context for the conversion.Returns:
The converted value compatible with the source type
-