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.
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.
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?
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:"
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.
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.
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: ""
Caused by: java.text.ParseException: Unparseable date: ""
... 4 more