Package com.oorian.data.converter
Class StringToLocalDateConverter
java.lang.Object
com.oorian.data.converter.StringToLocalDateConverter
Converts between
String and LocalDate.
Uses a configurable date format pattern. The default pattern is "yyyy-MM-dd"
(ISO-8601 date format).
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new converter with the ISO-8601 date format ("yyyy-MM-dd").StringToLocalDateConverter(String pattern) Creates a new converter with the specified date format pattern.StringToLocalDateConverter(DateTimeFormatter formatter, String errorMessage) Creates a new converter with the specified formatter and error message. -
Method Summary
Modifier and TypeMethodDescriptionconvertToModel(String value) Converts a presentation value to its model representation.convertToPresentation(LocalDate value) Converts a model value to its presentation representation.
-
Constructor Details
-
StringToLocalDateConverter
public StringToLocalDateConverter()Creates a new converter with the ISO-8601 date format ("yyyy-MM-dd"). -
StringToLocalDateConverter
Creates a new converter with the specified date format pattern.- Parameters:
pattern- the date format pattern (e.g., "yyyy-MM-dd", "MM/dd/yyyy")
-
StringToLocalDateConverter
Creates a new converter with the specified formatter and error message.- Parameters:
formatter- the date formattererrorMessage- the error message shown when conversion fails
-
-
Method Details
-
convertToModel
Description copied from interface:ConverterConverts a presentation value to its model representation.- Specified by:
convertToModelin interfaceConverter<String,LocalDate> - Parameters:
value- the presentation value to convert (may be null)- Returns:
- the model value
- Throws:
ConversionException- if conversion fails
-
convertToPresentation
Description copied from interface:ConverterConverts a model value to its presentation representation.- Specified by:
convertToPresentationin interfaceConverter<String,LocalDate> - Parameters:
value- the model value to convert (may be null)- Returns:
- the presentation value
-