Want to go 1 month back of the deliverd date: TalendDate.addDate

One Star

Want to go 1 month back of the deliverd date: TalendDate.addDate

Hi All,
I get from an excel file a string deliverd as date. This string is yyyyMMddhhmmss (Sample 20161012213300 = 12 Oct 2016 21:33:00).
I am able to parse this to date by using TalendDate.parseDate("yyyyMMddhhmmss", row1.Report_Date)
But now I want to move one month back so the deliverd date is still 20161012213300 Converted to 12 Oct 2016 and Then I want to add instead of Oct it should be Sep
I have tried it with addDate, but I get an error:
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "20160930120000"
    at routines.TalendDate.parseDate(TalendDate.java:857)
    at routines.TalendDate.parseDate(TalendDate.java:801)
    at mlm.tutorexcel_0_1.TutorExcel.tFileExcelWorkbookOpen_1Process(TutorExcel.java:5167)
Thanks for the feedBack
Community Manager

Re: Want to go 1 month back of the deliverd date: TalendDate.addDate

Hi
Try this code on tJavaRow:
output_row.DateColumn=TalendDate.addDate(TalendDate.parseDate("yyyyMMddHHmmss", input_row.stringDateColumn),"-1","MM");
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Want to go 1 month back of the deliverd date: TalendDate.addDate

Thanks for your feedback,  this works.