File tree Expand file tree Collapse file tree
rdb/rdb-side/src/main/java/com/dtstack/flink/sql/side/rdb/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -223,10 +223,15 @@ public static Date getDate(Object obj) {
223223 return null ;
224224 }
225225 if (obj instanceof String ) {
226- return Date .valueOf ((String ) obj );
226+ SimpleDateFormat format = new SimpleDateFormat ("yyyy-MM-dd" );
227+ try {
228+ return new Date (format .parse ((String ) obj ).getTime ());
229+ } catch (ParseException e ) {
230+ throw new RuntimeException ("String convert to Date fail." );
231+ }
227232 } else if (obj instanceof Timestamp ) {
228233 return new Date (((Timestamp ) obj ).getTime ());
229- }else if (obj instanceof Date ){
234+ } else if (obj instanceof Date ) {
230235 return (Date ) obj ;
231236 }
232237 throw new RuntimeException ("not support type of " + obj .getClass () + " convert to Date." );
@@ -239,9 +244,9 @@ public static Timestamp getTimestamp(Object obj) {
239244 if (obj instanceof Timestamp ) {
240245 return (Timestamp ) obj ;
241246 } else if (obj instanceof Date ) {
242- return Timestamp . valueOf (( String ) obj );
247+ return new Timestamp ((( Date ) obj ). getTime () );
243248 } else if (obj instanceof String ) {
244- return Timestamp . valueOf (( String ) obj );
249+ return new Timestamp ( getDate ( obj ). getTime () );
245250 }
246251 throw new RuntimeException ("not support type of " + obj .getClass () + " convert to Date." );
247252 }
You can’t perform that action at this time.
0 commit comments