Class StringToDateConverter

java.lang.Object
com.oorian.data.converter.StringToDateConverter
All Implemented Interfaces:
Converter<String,Date>

public class StringToDateConverter extends Object implements Converter<String,Date>
Converts between String and Date.

Uses a configurable date format pattern. The default pattern is "yyyy-MM-dd".

Since:
2.1
Version:
1.0
Author:
Marvin P. Warble Jr.
  • Constructor Details

    • StringToDateConverter

      public StringToDateConverter()
      Creates a new converter with the default pattern ("yyyy-MM-dd").
    • StringToDateConverter

      public StringToDateConverter(String pattern)
      Creates a new converter with the specified date format pattern.
      Parameters:
      pattern - the date format pattern (e.g., "yyyy-MM-dd", "MM/dd/yyyy")
    • StringToDateConverter

      public StringToDateConverter(String pattern, String errorMessage)
      Creates a new converter with the specified pattern and error message.
      Parameters:
      pattern - the date format pattern
      errorMessage - the error message shown when conversion fails
  • Method Details

    • convertToModel

      public Date convertToModel(String value) throws ConversionException
      Description copied from interface: Converter
      Converts a presentation value to its model representation.
      Specified by:
      convertToModel in interface Converter<String,Date>
      Parameters:
      value - the presentation value to convert (may be null)
      Returns:
      the model value
      Throws:
      ConversionException - if conversion fails
    • convertToPresentation

      public String convertToPresentation(Date value)
      Description copied from interface: Converter
      Converts a model value to its presentation representation.
      Specified by:
      convertToPresentation in interface Converter<String,Date>
      Parameters:
      value - the model value to convert (may be null)
      Returns:
      the presentation value