Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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.
Labels (2)
14 Replies
Anonymous
Not applicable
Author

hi,
I think that you should use tFileProperties (file/management) componenent to get this information
regards
laurent
Anonymous
Not applicable
Author

it is the modification date I need the creation date...
thanks
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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 ....??? 0683p000009MPcz.png 0683p000009MPcz.png

Witch class I have to use in talend ???
TIS 3.0.2 r 20205
Thanks
Anonymous
Not applicable
Author

hi,
ypu have to import it in your routine .
++
Anonymous
Not applicable
Author

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 ??
Anonymous
Not applicable
Author

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.
++
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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;
}