Using TalendDate addDate Method

One Star

Using TalendDate addDate Method

I'm trying to use the TalendDate addDate method. I need to be able to add 90 days to any given date to properly generate a date that many days from now. Is the addDate method the proper way to do this? If so, how do I go about using it. I can't seem to make sense of the Help section within the program and I haven't been able to find any useful instructions online.
One Star

Re: Using TalendDate addDate Method

Hi and welcome to the forum,
Put your input file into a tMap component, on the output side of the tMap component.
In the expression field on the ouput side of the tMap, use TalendDate.addDate(row1.MyDate, 90, "dd")
You will have to replace row1.MyDate with the name of your date field.
Good luck,
One Star

Re: Using TalendDate addDate Method

Thanks for your quick reply. Do I need to include the date pattern? If so, how should it be shown? My input value is a string.
Also, what will the output data type be? Can I keep it as a string?
One Star

Re: Using TalendDate addDate Method

I've tried doing this but when I run the test in the expression builder with a legitimate example value, I get "Exception in thread "main" java.lang.Error: Unresolved compilation problem:"
One Star

Re: Using TalendDate addDate Method

You need to drop the "yyyyMMdd".
Try this: TalendDate.addDate(row1.TransactionDate,90,"dd")
One Star

Re: Using TalendDate addDate Method

I've tried dropping what you suggested but I get an error message: "The method addDate(Date, int, String) in the type TalendDate is not applicable for the arguments (String, int, String)"
My input is a string of format yyyyMMdd. I'd like my output to either be a date type or a string.
And this is my code now as you suggested: TalendDate.addDate(row1.TransactionDate,90,"dd")
The expression builder still throws a flag. Perhaps it would work if I actually did a run but I'm not ready with the rest of my job yet to do that.
Thanks for your help. I just don't know what is going wrong.
One Star

Re: Using TalendDate addDate Method

Ok. row1.TransactionDate is currently formatted as a String. You will need to change that to a date. You can either do that at the point of import, or use nest the parseDate function inside the adddate.
TalendDate.addDate(TalendDate.parseDate("yyyyMMdd", row1.TransactionDate),90,"dd")
One Star

Re: Using TalendDate addDate Method

I've tried getting it all set up and I gave my job a test run. Any ideas now?
Exception in component tMap_1_TMAP_IN
java.lang.RuntimeException: java.text.ParseException: Unparseable date: ""
at routines.TalendDate.parseDate(
at bonusme.transaction_processing_0_1.Transaction_Processing.tFileList_1Process(
at bonusme.transaction_processing_0_1.Transaction_Processing.tMysqlConnection_1Process(
at bonusme.transaction_processing_0_1.Transaction_Processing.runJobInTOS(
at bonusme.transaction_processing_0_1.Transaction_Processing.main(
Caused by: java.text.ParseException: Unparseable date: ""
at java.text.DateFormat.parse(
at routines.TalendDate.parseDate(
... 4 more


Talend named a Leader.

Get your copy


Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables


How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration


Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.