Package dev.orne.beans.converters
Class MonthConverter
java.lang.Object
org.apache.commons.beanutils.converters.AbstractConverter
dev.orne.beans.converters.AbstractDateTimeConverter
dev.orne.beans.converters.MonthConverter
- All Implemented Interfaces:
org.apache.commons.beanutils.Converter
Implementation of
Converter that converts Month instances
to and from String using "YYYY-MM" as String
representation.- Since:
- 0.1
- Version:
- 1.0, 2020-05
- Author:
- (w) Iker Hernaez
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DateTimeFormatterThe month by full text parser, for default locale.static final DateTimeFormatterThe month by short text parser, for default locale.static final DateTimeFormatterThe month by short text parser, for default locale.static final DateTimeFormatterThe month by value parser. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance that throws aConversionExceptionif an error occurs.MonthConverter(@NotNull DateTimeFormatter formatter) Creates a new instance that throws aConversionExceptionif an error occurs.MonthConverter(@NotNull DateTimeFormatter formatter, Month defaultValue) Creates a new instance that returns a default value if an error occurs.MonthConverter(Month defaultValue) Creates a new instance that returns a default value if an error occurs. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringconvertToString(Object value) protected <T> TconvertToType(@NotNull Class<T> type, Object value) protected <T extends TemporalAccessor>
TfromTemporalAccessor(@NotNull Class<T> type, @NotNull TemporalAccessor value) Converts theTemporalAccessorpassed as argument to the specified type.protected @NotNull Class<?>Methods inherited from class dev.orne.beans.converters.AbstractDateTimeConverter
addParsers, addParsers, getFormatter, getLogger, getParsers, parse, parseString, setParsers, setParsersMethods inherited from class org.apache.commons.beanutils.converters.AbstractConverter
conversionException, convert, convertArray, getDefault, handleError, handleMissing, isUseDefault, setDefaultValue, toString
-
Field Details
-
BY_VALUE_PARSER
The month by value parser. -
BY_FULL_TEXT_PARSER
The month by full text parser, for default locale. -
BY_SHORT_TEXT_PARSER
The month by short text parser, for default locale. -
BY_NARROW_TEXT_PARSER
The month by short text parser, for default locale.
-
-
Constructor Details
-
MonthConverter
public MonthConverter()Creates a new instance that throws aConversionExceptionif an error occurs. -
MonthConverter
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
-
MonthConverter
Creates a new instance that throws aConversionExceptionif an error occurs.- Parameters:
formatter- The temporal value formatter and default parser
-
MonthConverter
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:
getDefaultTypein classAbstractDateTimeConverter
-
convertToType
- Overrides:
convertToTypein classAbstractDateTimeConverter
-
fromTemporalAccessor
protected <T extends TemporalAccessor> T fromTemporalAccessor(@NotNull @NotNull Class<T> type, @NotNull @NotNull TemporalAccessor value) Converts theTemporalAccessorpassed as argument to the specified type.- Specified by:
fromTemporalAccessorin classAbstractDateTimeConverter- Type Parameters:
T- The expected type ofTemporalAccessor- Parameters:
type- The expected type ofTemporalAccessorvalue- TheTemporalAccessorto convert to the expected type- Returns:
- The converted
TemporalAccessorof the expected type
-
convertToString
- Overrides:
convertToStringin classAbstractDateTimeConverter
-