Package com.oorian.data.converter
Class StringToLocalDateTimeConverter
java.lang.Object
com.oorian.data.converter.StringToLocalDateTimeConverter
- All Implemented Interfaces:
Converter<String,LocalDateTime>
public class StringToLocalDateTimeConverter
extends Object
implements Converter<String,LocalDateTime>
Converts between
String and LocalDateTime.
Uses a configurable date-time format pattern. The default pattern is
"yyyy-MM-dd'T'HH:mm:ss" (ISO-8601 date-time format).
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new converter with the ISO-8601 date-time format.StringToLocalDateTimeConverter(String pattern) Creates a new converter with the specified date-time format pattern.StringToLocalDateTimeConverter(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.Converts a model value to its presentation representation.
-
Constructor Details
-
StringToLocalDateTimeConverter
public StringToLocalDateTimeConverter()Creates a new converter with the ISO-8601 date-time format. -
StringToLocalDateTimeConverter
Creates a new converter with the specified date-time format pattern.- Parameters:
pattern- the date-time format pattern (e.g., "yyyy-MM-dd HH:mm")
-
StringToLocalDateTimeConverter
Creates a new converter with the specified formatter and error message.- Parameters:
formatter- the date-time 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,LocalDateTime> - 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,LocalDateTime> - Parameters:
value- the model value to convert (may be null)- Returns:
- the presentation value
-