Five Stars

NullpointerException and String to Date

I am doing all of these transformations in tMap.

 

Actual_Close_Date is a string data type in the data source. First I tried,

TalendDate.parseDate("MM/dd/yyyy",row.Actual_Close_Date) it gives an error:

Unparseable date: "Fri Nov 15 00:00:00 CST 2013"

Then I tried:

TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy",row2.Actual_Close_Date) it gives an error:

java.lang.NullPointerException

Then I tried:

row2.Actual_Close_Date == null ? 0 :TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy",row2.Actual_Close_Date) it gives an error:

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

Then I tried:

(row2.Actual_Close_Date.equals(""))||(row2.Actual_Close_Date==null) ? null : 
(TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy",row2.Actual_Close_Date))

 Error it gives:

java.lang.NullPointerException

I have run out of options and googlefu has dried up for me.

The format I am requesting is "MM/dd/yyyy".

How can I fix this please. Any insights would be greatly appreciated.

  • Data Integration
1 ACCEPTED SOLUTION

Accepted Solutions
Nine Stars

Re: NullpointerException and String to Date

You were close!

 

This example:

row2.Actual_Close_Date == null ? 0 :TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy",row2.Actual_Close_Date)

...will work if you replace 0 with a valid date or the word null.

1 REPLY
Nine Stars

Re: NullpointerException and String to Date

You were close!

 

This example:

row2.Actual_Close_Date == null ? 0 :TalendDate.parseDate("EEE MMM dd HH:mm:ss Z yyyy",row2.Actual_Close_Date)

...will work if you replace 0 with a valid date or the word null.