Class YearMonthConverter

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

@API(status=STABLE, since="0.1") public class YearMonthConverter extends AbstractDateTimeConverter
Implementation of Converter that converts YearMonth instances to and from String using "YYYY-MM" as String representation.
Since:
0.1
Version:
1.0, 2020-05
Author:
(w) Iker Hernaez
  • Field Details

    • ISO_8601_PARSER

      public static final DateTimeFormatter ISO_8601_PARSER
      The month-day by value parser.
    • BY_FULL_TEXT_PARSER

      public static final DateTimeFormatter BY_FULL_TEXT_PARSER
      The month-day by full text parser, for default locale.
    • BY_SHORT_TEXT_PARSER

      public static final DateTimeFormatter BY_SHORT_TEXT_PARSER
      The month-day by short text parser, for default locale.
    • BY_NARROW_TEXT_PARSER

      public static final DateTimeFormatter BY_NARROW_TEXT_PARSER
      The month-day by short text parser, for default locale.
  • Constructor Details

    • YearMonthConverter

      public YearMonthConverter()
      Creates a new instance that throws a ConversionException if an error occurs, using ISO-8601 as default conversion format.
    • YearMonthConverter

      public YearMonthConverter(YearMonth defaultValue)
      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
    • YearMonthConverter

      public YearMonthConverter(@NotNull @NotNull DateTimeFormatter formatter)
      Creates a new instance that throws a ConversionException if an error occurs.
      Parameters:
      formatter - The temporal value formatter and default parser
    • YearMonthConverter

      public YearMonthConverter(@NotNull @NotNull DateTimeFormatter formatter, YearMonth defaultValue)
      Creates a new instance that returns a default value if an error occurs.
      Parameters:
      formatter - The temporal value formatter and default parser
      defaultValue - The default value to be returned if the value to be converted is missing or an error occurs converting the value
  • Method Details

    • getDefaultType

      @NotNull protected @NotNull Class<?> getDefaultType()
      Specified by:
      getDefaultType in class AbstractDateTimeConverter
    • fromTemporalAccessor

      protected <T extends TemporalAccessor> T fromTemporalAccessor(@NotNull @NotNull Class<T> type, @NotNull @NotNull TemporalAccessor value)
      Converts the TemporalAccessor passed as argument to the specified type.
      Specified by:
      fromTemporalAccessor in class AbstractDateTimeConverter
      Type Parameters:
      T - The expected type of TemporalAccessor
      Parameters:
      type - The expected type of TemporalAccessor
      value - The TemporalAccessor to convert to the expected type
      Returns:
      The converted TemporalAccessor of the expected type