One Star

tmap java.lang.nullpointerexception

Hi,
I encountered java.lang.nullpointerexception error in my tmap. I discovered that in my tmap, I added the following expression
==> row1.promo_start_date.getTime()<0?null:row1.promo_start_date
The above expression works fine if the promo_start_date contains 0000-00-00; however, it will fail with java.lang.nullpointerexception error when the promo_start_date contains NULL.
I tried to define the following expression to transform the data to NULL if the promo_start_date = 0000-00-00 or promo_start_date = NULL; however, it doesn't work with error "the operator == is undefined for the argument type(s) long, null" message:
==> row1.promo_start_date.getTime()<0||row1.promo_start_date.getTime()==null?null:row1.promo_start_date
Can you please help how should I define the expression in my tmap so that it will transfer the date to NULL if the date = 0000-00-00 or NULL
Thanks! Any help is really appreciated!
6 REPLIES
Community Manager

Re: tmap java.lang.nullpointerexception

Hello guy
try
row1.promo_start_date==null||row1.promo_start_date.getTime()<0l?null:row1.promo_start_date

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tmap java.lang.nullpointerexception

Hi Shong,
Thanks for your help, it works great now!
Can you please clarify the following:
1) What does row1.promo_start_date.getTime() < 01 means?
2) What is the difference between row1.promo_start_date.getTime() < 0 & row1.promo_start_date.getTime() < 01?
Thanks again!
Community Manager

Re: tmap java.lang.nullpointerexception

Hello
Can you please clarify the following:

Oh, sorry, this is my wrong spell here. It should be:
row1.promo_start_date==null||row1.promo_start_date.getTime()<0?null:row1.promo_start_date
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tmap java.lang.nullpointerexception

Hi Shong,
Thanks for the clarification and your help!!
have a nice day!

Re: tmap java.lang.nullpointerexception

Hi,
I am using tELTmysqlMap for my query and since currently there is no result for the query, tELTmysqloutput gives me an error:Exception in component tELTMysqlOutput_1
java.lang.NullPointerException, I am not sure why is tht. Could you help me.

Re: tmap java.lang.nullpointerexception

xception in component tFileInputExcel_2
java.lang.IllegalStateException: Bad cell type (3)
at org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator.evaluate(XSSFFormulaEvaluator.java:102)

what does this error mean?