Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am converting two strings into date data types but keeping into an error I do not fully comprehend.
This is my snippet in tMap output into the database:
(row1.Week == null || row1.Week == ("")) ? "" : TalendDate.parseDate("MM/dd/yyyy",row1.Week)
Type mismatch: cannot convert from Object&Serializable&Comparable<?> to Date
Thanks in advance,
CM
row1.Week == ("") ? "" : TalendDate.parseDate("MM/dd/yyyy",row1.Week)
row1.Week == null || "".equals(row1.Week) ? "" : TalendDate.parseDate("MM/dd/yyyy",row1.Week)
Hello @Colleen @TRF @vapukov ,
I am facing the same issue.
When i use (row1.Dat == null || row1.Date.equals(""))?null: (TalendDate.parseDate("yyyy-mm-dd'T'hh:mm:ss.SSS'Z'",row1.Date)) , the I get rid of the error Object&Serializable&Comparable<?> to Date.
But now I am getting Null Pointer Exception when value in row1.Date is null.
Please reply asap.
Thanks in advance.
Yes, the Exception is thrown because of the above mentioned Expression (i.e. (row1.Date == null || row1.Date.equals(""))?null: (TalendDate.parseDate("yyyy-mm-dd'T'hh:mm:ss.SSS'Z'",row1.Date)) ).
Error: Exception in component tMap_1 java.lang.NullPointerException
tMap:
@KrupalGharat, I have tested your expression and confirmed that this expression will not throw NPE. Please make some testing, remove this expression or column from the output table and run again.