Class DateTimeCoercion

java.lang.Object
io.github.connellite.util.internal.DateTimeCoercion

public class DateTimeCoercion extends Object
Date and time coercion used by TypeCoercionUtil.
  • Constructor Details

    • DateTimeCoercion

      public DateTimeCoercion()
  • Method Details

    • supports

      public static boolean supports(Class<?> targetType)
      Returns whether targetType is a date or time type handled here.
      Parameters:
      targetType - desired type, never null
      Returns:
      true for JDBC, Date, and java.time date/time targets
    • coerce

      public static <T> T coerce(Object raw, Class<T> targetType)
      Coerces raw toward a date or time targetType. supports(Class) is true for targetType. An incompatible value yields null. A non-blank string that is not a date or time throws.
      Type Parameters:
      T - target type
      Parameters:
      raw - source value, never null
      targetType - date or time type to coerce toward
      Returns:
      coerced value, or null when raw does not match targetType
      Throws:
      TypeCoercionException - when a non-blank string is not a date or time