Package dev.orne.beans.converters
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
ConstructorDescriptionCreates a new instance that throws aConversionException
if an error occurs.DateConverter
(@NotNull org.apache.commons.beanutils.Converter instantConverter) Creates a new instance that throws aConversionException
if an error occurs.DateConverter
(@NotNull org.apache.commons.beanutils.Converter instantConverter, Date defaultValue) Creates a new instance that returns a default value if an error occurs.DateConverter
(Date defaultValue) Creates a new instance that returns a default value if an error occurs. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
convertToString
(Object value) protected <T> T
convertToType
(@NotNull Class<T> type, Object value) protected @NotNull org.apache.commons.beanutils.Converter
Returns the converter to use when convertingInstant
instances.Methods inherited from class org.apache.commons.beanutils.converters.AbstractConverter
conversionException, convert, convertArray, getDefault, handleError, handleMissing, isUseDefault, setDefaultValue, toString
-
Constructor Details
-
DateConverter
public DateConverter()Creates a new instance that throws aConversionException
if an error occurs. -
DateConverter
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(@NotNull @NotNull org.apache.commons.beanutils.Converter instantConverter) Creates a new instance that throws aConversionException
if an error occurs.- Parameters:
instantConverter
- The converter to use when convertingInstant
instances
-
DateConverter
public DateConverter(@NotNull @NotNull org.apache.commons.beanutils.Converter instantConverter, Date defaultValue) Creates a new instance that returns a default value if an error occurs.- Parameters:
instantConverter
- The converter to use when convertingInstant
instancesdefaultValue
- The default value to be returned if the value to be converted is missing or an error occurs converting the value
-
-
Method Details
-
getInstantConverter
@NotNull protected @NotNull org.apache.commons.beanutils.Converter getInstantConverter()Returns the converter to use when convertingInstant
instances.- Returns:
- The converter to use when converting
Instant
instances
-
getDefaultType
- Specified by:
getDefaultType
in classorg.apache.commons.beanutils.converters.AbstractConverter
-
convertToType
- Specified by:
convertToType
in classorg.apache.commons.beanutils.converters.AbstractConverter
- Throws:
Throwable
-
convertToString
- Overrides:
convertToString
in classorg.apache.commons.beanutils.converters.AbstractConverter
- Throws:
Throwable
-