@@ -46,6 +46,9 @@ static Object convert(final Object source, final Class<?> target) { // NOSONAR
4646 }
4747 if (target == Duration .class ) {
4848 return convertDuration (source );
49+ }
50+ if (target == Timestamp .class ) {
51+ return convertTimestamp (source );
4952 } else {
5053 LOGGER .debug ("No converter found to convert " + source .getClass ().getSimpleName () + " to " + target
5154 .getSimpleName ());
@@ -61,7 +64,7 @@ private static Character convertToCharacter(final String source) {
6164 LOGGER .debug ("Implicit conversion to Character from String only supported if String not longer than 1" );
6265 throw new IllegalArgumentException ("String to long" );
6366 }
64- if (source .length () == 0 )
67+ if (source .isEmpty () )
6568 return ' ' ;
6669 return source .charAt (0 );
6770 }
@@ -138,6 +141,17 @@ private static OffsetDateTime convertTemporalToOffsetDateTime(final Object sourc
138141 return OffsetDateTime .parse ((String ) source );
139142 }
140143
144+ private static Timestamp convertTimestamp (Object source ) {
145+ if (source instanceof LocalDateTime ldt )
146+ return Timestamp .valueOf (ldt );
147+ if (source instanceof LocalDate ld )
148+ return Timestamp .valueOf (LocalDateTime .of (ld , LocalTime .of (0 , 0 )));
149+ if (source instanceof String s )
150+ return Timestamp .valueOf (s );
151+ LOGGER .debug ("No converter found to convert " + source .getClass ().getSimpleName () + " to Timestamp" );
152+ throw new IllegalArgumentException (createCastException (source , Timestamp .class ));
153+ }
154+
141155 public static Class <?> boxed (final Class <?> javaType ) {
142156 if (javaType == int .class ) return Integer .class ;
143157 if (javaType == long .class ) return Long .class ;
0 commit comments