Package com.vaadin.data.converter
Class StringToDateConverter
- java.lang.Object
-
- com.vaadin.data.converter.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 fromDatetoStringand back. Uses the given locale andDateFormatfor 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 Summary
Constructors Constructor Description StringToDateConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Result<java.util.Date>convertToModel(java.lang.String value, ValueContext context)Converts the given value from model type to presentation type.java.lang.StringconvertToPresentation(java.util.Date value, ValueContext context)Converts the given value from presentation type to model type.protected java.text.DateFormatgetFormat(java.util.Locale locale)Returns the format used byconvertToPresentation(Date, ValueContext)andconvertToModel(String, ValueContext).
-
-
-
Method Detail
-
getFormat
protected java.text.DateFormat getFormat(java.util.Locale locale)
Returns the format used byconvertToPresentation(Date, ValueContext)andconvertToModel(String, ValueContext).- Parameters:
locale- The locale to use- Returns:
- A DateFormat instance
-
convertToModel
public Result<java.util.Date> convertToModel(java.lang.String value, ValueContext context)
Description copied from interface:ConverterConverts the given value from model type to presentation type.A converter can optionally use locale to do the conversion.
- Specified by:
convertToModelin interfaceConverter<java.lang.String,java.util.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
public java.lang.String convertToPresentation(java.util.Date value, ValueContext context)Description copied from interface:ConverterConverts the given value from presentation type to model type.A converter can optionally use locale to do the conversion.
- Specified by:
convertToPresentationin interfaceConverter<java.lang.String,java.util.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
-
-