One Star

File date created

Hi,
I need to recover the created date of et file...
I don't find it on the forum ...
Thanks.
TIS 3.0.2.
14 REPLIES
Seventeen Stars

Re: File date created

hi,
I think that you should use tFileProperties (file/management) componenent to get this information
regards
laurent
One Star

Re: File date created

it is the modification date I need the creation date...
thanks
Seventeen Stars

Re: File date created

on which OS are you working ?
On *nix date creation file isn't store on the system i think !
only modification date can be access for a file ; so when you create a file it means a "modification" of a file (its creation)
you 've got this article (french one) about date creation file .
hope its help you
laurent
One Star

Re: File date created

Well,
The modification date should be enough...
So I have another probleme, this is my routine:
public static Date modifDate(String chemin)
{
File f = new File(chemin);
Date lastModify= new Date (f.lastModified());

return lastModify;
}

I have an error on the word file...
The auto-completion doesn't give a class like util.io.file ....??? Smiley Sad Smiley Sad

Witch class I have to use in talend ???
TIS 3.0.2 r 20205
Thanks
Seventeen Stars

Re: File date created

hi,
ypu have to import it in your routine .
++
One Star

Re: File date created

OK thanks,
Other one ...sorry.
I have my date in long format HOW can I have a String with the format yyyyMM ???
In my routine I have the date at date format with:
Date lastModify= new Date (date_long);
But how to have a string format with yyyyMM ??
Seventeen Stars

Re: File date created

I think you have to use the TalendDate routines method formatDate(String pattern, java.util.Date date).where pattern is your format date (yyyyMM)
you can have a look in code source Routines->System->TalendDate for more details.
You can use it directly in your own routine or with you return "lastModify" value.
But you can also do it directly with Talend's component.
++
Seventeen Stars

Re: File date created

here simple example using Talend Component
tFileProperties ----main---->tFilterColumn ----main---->tJavaRow
in your schema tFilterColumn keep just mtime (long) for your application
in tJavaRow catch the input row ; set to a type date and format in yyyyMM
java.util.Date date = new java.util.Date(input_row.mtime);
System.out.println(TalendDate.formatDate("yyyyMM",date));
// or in one 'shoot' :
// System.out.println(TalendDate.formatDate("yyyyMM",new java.util.Date(input_row.mtime)));

for result
connected
200904
disconnected

regards
laurent
One Star

Re: File date created

Thanks a lot,
i find a different way with a routines and using the file path:
public static String monthDate(String chemin)
{
File f = new File(chemin);
Date lastModify= new Date (f.lastModified());

SimpleDateFormat formatDateJour = new SimpleDateFormat("MM");
String dateFormatee = formatDateJour.format(lastModify);
return dateFormatee;
}
One Star

Re: File date created

Hi
I am trying to do something similar
Simple TfileList --> TfileProperties --> TJavaRow
In the javarow I have the following code:
System.out.println("mtime = "+row2.mtime + " Converted date = " + TalendDate.formatDate("yyyy/mm/dd",new java.util.Date(row2.mtime)) + " row2.mtime_string = " + row2.mtime_string);
The output for the converted date is however invalid and does not match the mtime_string:
mtime = 1240347490000 Converted date = 2009/58/21 row2.mtime_string = Tue Apr 21 22:58:10 SAST 2009
mtime = 1240261066000 Converted date = 2009/57/20 row2.mtime_string = Mon Apr 20 22:57:46 SAST 2009
mtime = 1240261102000 Converted date = 2009/58/20 row2.mtime_string = Mon Apr 20 22:58:22 SAST 2009
mtime = 1240261130000 Converted date = 2009/58/20 row2.mtime_string = Mon Apr 20 22:58:50 SAST 2009
mtime = 1240261158000 Converted date = 2009/59/20 row2.mtime_string = Mon Apr 20 22:59:18 SAST 2009
mtime = 1240261184000 Converted date = 2009/59/20 row2.mtime_string = Mon Apr 20 22:59:44 SAST 2009
mtime = 1240347526000 Converted date = 2009/58/21 row2.mtime_string = Tue Apr 21 22:58:46 SAST 2009
mtime = 1240347558000 Converted date = 2009/59/21 row2.mtime_string = Tue Apr 21 22:59:18 SAST 2009
mtime = 1240347584000 Converted date = 2009/59/21 row2.mtime_string = Tue Apr 21 22:59:44 SAST 2009
Any help would be appreciated
Andre
Community Manager

Re: File date created

Hello Andre
change "yyyy/mm/dd" to "yyyy/MM/dd"
Best regards

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

Re: File date created

Thank you, works perfectly.
Five Stars

Re: File date created

Hi kzone,
I have a similar requirement, INPUT_ROW.mtime is returning the original file create date. similarly i need the last modified date of that particular file.
Could you please let me know what is the method to retrieve the last modified date.
Thanks in-advance!
Regards,
Chaitanya
Five Stars

Re: File date created

Hi all,
I got the answer.
Thank you very much for this post. Its really help me a lot.
Especially thanks to kzone!!
Regards,
Chaitnaya