Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

cannot convert from Object&Serializable&Comparable<?> to Date

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

Labels (2)
10 Replies
TRF
Champion II
Champion II

Hi,
I think it's because TalendDate.parseDate returns a date datatype and the left part of the ternary operator returns a String.
http://stackoverflow.com/questions/25190374/type-mismatch-in-a-conditional-operator-java

Regards,
TRF
Anonymous
Not applicable
Author

Thanks,
Even when I do

row1.Week == ("") ? "" : TalendDate.parseDate("MM/dd/yyyy",row1.Week) 

it still returns the same error. How can I encapsulate the null (blank) and parseDate so the field can be converted to a date type. Any assistance would be appreciated.
TRF
Champion II
Champion II

Try 
row1.Week == null || "".equals(row1.Week) ? "" : TalendDate.parseDate("MM/dd/yyyy",row1.Week)
Anonymous
Not applicable
Author

Thanks again but the error persists on my side. I google-fu the error but since it is Talend oriented could not get SO to show anything.
vapukov
Master II
Master II

What source and target columns type in tMap?

for example if row1.Week - text, use not == but row1.week.equals("")
but the best - add full information there, what from left and what from right
KrupalGharat
Contributor II
Contributor II

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.

Anonymous
Not applicable
Author

@KrupalGharat, can you confirm the NPE is thrown by this expression? Do you have other java code expression? Can you upload a screenshot of tMap?

Regards
Shong
KrupalGharat
Contributor II
Contributor II

@shong 

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:
0683p000009M9PH.png

Anonymous
Not applicable
Author

@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.