public class StringToDateConverter extends Object implements Converter<String,Date>
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.
| Constructor and Description |
|---|
StringToDateConverter() |
| Modifier and Type | Method and Description |
|---|---|
Result<Date> |
convertToModel(String value,
ValueContext context)
Converts the given value from presentation type to model type.
|
String |
convertToPresentation(Date value,
ValueContext context)
Converts the given value from model type to presentation type.
|
protected DateFormat |
getFormat(Locale locale)
Returns the format used by
convertToPresentation(Date, ValueContext) and
convertToModel(String, ValueContext). |
protected DateFormat getFormat(Locale locale)
convertToPresentation(Date, ValueContext) and
convertToModel(String, ValueContext).locale - The locale to usepublic Result<Date> convertToModel(String value, ValueContext context)
ConverterA converter can optionally use locale to do the conversion.
convertToModel in interface Converter<String,Date>value - The value to convert. Can be nullcontext - The value context for the conversion.public String convertToPresentation(Date value, ValueContext context)
ConverterA converter can optionally use locale to do the conversion.
convertToPresentation in interface Converter<String,Date>value - The value to convert. Can be nullcontext - The value context for the conversion.Copyright © 2025. All rights reserved.