Package dev.orne.beans.converters
Class ZonedDateTimeConverter
java.lang.Object
org.apache.commons.beanutils.converters.AbstractConverter
dev.orne.beans.converters.AbstractDateTimeConverter
dev.orne.beans.converters.ZonedDateTimeConverter
- All Implemented Interfaces:
org.apache.commons.beanutils.Converter
@API(status=STABLE,
since="0.1")
public class ZonedDateTimeConverter
extends AbstractDateTimeConverter
Implementation of
Converter
that converts ZonedDateTime
instances
to and from String
using ISO-8601 as String
representation by default.- Since:
- 0.1
- Version:
- 1.0, 2020-05
- Author:
- (w) Iker Hernaez
-
Constructor Summary
ConstructorDescriptionCreates a new instance that throws aConversionException
if an error occurs, using ISO-8601 as default conversion format.ZonedDateTimeConverter
(@NotNull DateTimeFormatter formatter) Creates a new instance that throws aConversionException
if an error occurs.ZonedDateTimeConverter
(@NotNull DateTimeFormatter formatter, ZonedDateTime defaultValue) Creates a new instance that returns a default value if an error occurs.ZonedDateTimeConverter
(ZonedDateTime defaultValue) Creates a new instance that returns a default value if an error occurs, using ISO-8601 as default conversion format. -
Method Summary
Modifier and TypeMethodDescriptionprotected <T extends TemporalAccessor>
TfromTemporalAccessor
(@NotNull Class<T> type, @NotNull TemporalAccessor value) Converts theTemporalAccessor
passed as argument to the specified type.protected @NotNull Class<?>
Methods inherited from class dev.orne.beans.converters.AbstractDateTimeConverter
addParsers, addParsers, convertToString, convertToType, getFormatter, getLogger, getParsers, parse, parseString, setParsers, setParsers
Methods inherited from class org.apache.commons.beanutils.converters.AbstractConverter
conversionException, convert, convertArray, getDefault, handleError, handleMissing, isUseDefault, setDefaultValue, toString
-
Constructor Details
-
ZonedDateTimeConverter
public ZonedDateTimeConverter()Creates a new instance that throws aConversionException
if an error occurs, using ISO-8601 as default conversion format. -
ZonedDateTimeConverter
Creates a new instance that returns a default value if an error occurs, using ISO-8601 as default conversion format.- Parameters:
defaultValue
- The default value to be returned if the value to be converted is missing or an error occurs converting the value
-
ZonedDateTimeConverter
Creates a new instance that throws aConversionException
if an error occurs.- Parameters:
formatter
- The temporal value formatter and default parser
-
ZonedDateTimeConverter
public ZonedDateTimeConverter(@NotNull @NotNull DateTimeFormatter formatter, ZonedDateTime defaultValue) Creates a new instance that returns a default value if an error occurs.- Parameters:
formatter
- The temporal value formatter and default parserdefaultValue
- The default value to be returned if the value to be converted is missing or an error occurs converting the value
-
-
Method Details
-
getDefaultType
- Specified by:
getDefaultType
in classAbstractDateTimeConverter
-
fromTemporalAccessor
protected <T extends TemporalAccessor> T fromTemporalAccessor(@NotNull @NotNull Class<T> type, @NotNull @NotNull TemporalAccessor value) Converts theTemporalAccessor
passed as argument to the specified type.- Specified by:
fromTemporalAccessor
in classAbstractDateTimeConverter
- Type Parameters:
T
- The expected type ofTemporalAccessor
- Parameters:
type
- The expected type ofTemporalAccessor
value
- TheTemporalAccessor
to convert to the expected type- Returns:
- The converted
TemporalAccessor
of the expected type
-