Class DateConverter

java.lang.Object
org.apache.commons.beanutils.converters.AbstractConverter
dev.orne.beans.converters.DateConverter
All Implemented Interfaces:
org.apache.commons.beanutils.Converter

@API(status=STABLE, since="0.3") public class DateConverter extends org.apache.commons.beanutils.converters.AbstractConverter
Implementation of Converter that converts Date instances to and from String using delegating in a instance of InstantConverter.
Since:
0.3
Version:
1.0, 2020-08
Author:
(w) Iker Hernaez
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance that throws a ConversionException if an error occurs.
    DateConverter(@Nullable Date defaultValue)
    Creates a new instance that returns a default value if an error occurs.
    DateConverter(org.apache.commons.beanutils.Converter instantConverter)
    Creates a new instance that throws a ConversionException if an error occurs.
    DateConverter(org.apache.commons.beanutils.Converter instantConverter, @Nullable Date defaultValue)
    Creates a new instance that returns a default value if an error occurs.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    protected <T> T
    convertToType(Class<T> type, Object value)
    protected Class<Date>
    protected org.apache.commons.beanutils.Converter
    Returns the converter to use when converting Instant instances.

    Methods inherited from class org.apache.commons.beanutils.converters.AbstractConverter

    conversionException, convert, convertArray, getDefault, handleError, handleMissing, isUseDefault, setDefaultValue, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DateConverter

      public DateConverter()
      Creates a new instance that throws a ConversionException if an error occurs.
    • DateConverter

      public DateConverter(@Nullable Date defaultValue)
      Creates a new instance that returns a default value if an error occurs.
      Parameters:
      defaultValue - The default value to be returned if the value to be converted is missing or an error occurs converting the value
    • DateConverter

      public DateConverter(org.apache.commons.beanutils.Converter instantConverter)
      Creates a new instance that throws a ConversionException if an error occurs.
      Parameters:
      instantConverter - The converter to use when converting Instant instances
    • DateConverter

      public DateConverter(org.apache.commons.beanutils.Converter instantConverter, @Nullable Date defaultValue)
      Creates a new instance that returns a default value if an error occurs.
      Parameters:
      instantConverter - The converter to use when converting Instant instances
      defaultValue - The default value to be returned if the value to be converted is missing or an error occurs converting the value
  • Method Details

    • getInstantConverter

      protected org.apache.commons.beanutils.Converter getInstantConverter()
      Returns the converter to use when converting Instant instances.
      Returns:
      The converter to use when converting Instant instances
    • getDefaultType

      protected Class<Date> getDefaultType()
      Specified by:
      getDefaultType in class org.apache.commons.beanutils.converters.AbstractConverter
    • convertToType

      protected <T> T convertToType(Class<T> type, Object value)
      Specified by:
      convertToType in class org.apache.commons.beanutils.converters.AbstractConverter
    • convertToString

      protected String convertToString(Object value)
      Overrides:
      convertToString in class org.apache.commons.beanutils.converters.AbstractConverter