Class DateLocaleConverter<D extends Date>

java.lang.Object
org.apache.commons.beanutils2.locale.BaseLocaleConverter<D>
org.apache.commons.beanutils2.locale.converters.DateLocaleConverter<D>
Type Parameters:
D - The Date type.
All Implemented Interfaces:
Converter<D>, LocaleConverter<D>
Direct Known Subclasses:
SqlDateLocaleConverter, SqlTimeLocaleConverter, SqlTimestampLocaleConverter

public class DateLocaleConverter<D extends Date> extends BaseLocaleConverter<D>
Standard LocaleConverter implementation that converts an incoming locale-sensitive String into a Date object, optionally using a default value or throwing a ConversionException if a conversion error occurs.
  • Constructor Details

    • DateLocaleConverter

      protected DateLocaleConverter(D defaultValue, Locale locale, String pattern, boolean useDefault, boolean locPattern, boolean lenient)
      Constructs a new instance.
      Parameters:
      defaultValue - default value.
      locale - locale.
      pattern - pattern.
      useDefault - use the default.
      locPattern - localized pattern.
      lenient - leniency policy.
  • Method Details

    • builder

      public static <B extends DateLocaleConverter.Builder<B, D>, D extends Date> B builder()
      Constructs a new builder.
      Type Parameters:
      B - The builder type.
      D - The Date type.
      Returns:
      a new builder.
    • isLenient

      public boolean isLenient()
      Tests whether date formatting is lenient.
      Returns:
      true if the DateFormat used for formatting is lenient
      See Also:
    • parse

      protected D parse(Object value, String pattern) throws ParseException
      Convert the specified locale-sensitive input object into an output object of the specified type.
      Specified by:
      parse in class BaseLocaleConverter<D extends Date>
      Parameters:
      value - The input object to be converted
      pattern - The pattern is used for the conversion
      Returns:
      the converted Date value
      Throws:
      ConversionException - if conversion cannot be performed successfully
      ParseException - if an error occurs parsing