Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III

Need to get previous date using getcurrentdate() in tftpget component

Folks,
I'm a talend newbie and a java newbie as well. I need some help from the experts here. I have a scenario where in my files are in remote location saying "remotefiledir/2013/05/01/clientid/xml1".
Similarly I have files in 2013/04/30/clientid/xml2. Now I need to get the previous day files using tftpget component. The current code would get the files 2013/05/01 when the current_date is 2013/05/02. But when the current date is 2013/05/01 it is not getting the file in location 2013/04/30 instead trying to get in 2013/05/00
Current code :
TalendDate.formatDate("yyyy",TalendDate.getCurrentDate())
+ "/" +TalendDate.formatDate("MM",TalendDate.getCurrentDate() )
+ "/" +TalendDate.formatDate("dd",TalendDate.addDate(TalendDate.getCurrentDate(),-1,"dd")
What is the way to use any talend routines in tftpget component which can get me the previous day files? If this can be achieved in tjavarow component..I need the sample code as well...Appreciate your help in this!!
Labels (4)
5 Replies
Anonymous
Not applicable

Of course, you should create your own routine to do that. A routine is quit easy to create. Simply create a class under the Code node in Studio and create a static method. The way to document it is a bit strange but that helps to have code completion in your job for your routine.
Here an example of what you are doing with the build routines:
Here a Routine class which I have written for a couple of timestamp and date manipulation. You would use the addDays method (like you with -1 to get yesterday).
To create a routine simple click right on the routines node and create a routine called TimestampUtil. After that copy&past this content in the routine (replace all existing), that it. Happy coding.
package routines;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
/*
* user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but


To see the whole post, download it here
OriginalPost.pdf
_AnonymousUser
Specialist III
Author

Thanks so much for the immediate reply!! Any other way to do it apart from the routines?? We just use the inbuilt system routines. I'm not sure how the customized routines will be migrated to production. Any other way like tjavarow component using java functions in it or using any other components? Thanks!!
Anonymous
Not applicable

Hi,
Perhaps this article Creating a user routine will point a light to you.
Best regards
Sabrina
alevy
Specialist

I would have thought your code would give you 2013/05/30 when the current date is 2013/05/01?
Why not just use TalendDate.formatDate("yyyy/MM/dd",TalendDate.addDate(TalendDate.getCurrentDate(),-1,"dd")) or TalendDate.addDate(TalendDate.getDate("yyyy/MM/dd"),"yyyy/MM/dd",-3,"dd")?
_AnonymousUser
Specialist III
Author

hi

i have a job which reads file from a directory and loads into a table.
tFilelist---->tfileinputdelimited----->tmap--->tverticaoutput
the file schema
file id
date
name

so what i want to achieve is compare today's date with "date" column in file if the "date" value is less than current date
i want to update in some table that "date" indicating its old data after the file is completely loaded making status filed in the table as loaded.
this status updation should be on file wise not on each record level in file.