Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2k views
in Java FTP by (260 points)
Searching the forum, some of the problems aim to the same tagret---list, parse and get the remote files' last modified time.


Here's some code usually be used and thank God it goes without any Exception.
FTPClientftp = new FTPClient();
...
ftp.setFTPFileFactory(new FTPFileFactory(unixFileParser));
ftp.setParserLocale(Locale.ENGLISH);
...
FTPFile[] files = ftp.dirDetails(".");
...
files[i].lastModified();
...


But as dirDetails() gets the modified time like "Mar-09-2006-01:45", I set ParserLocale to Locale.ENGLISH, and my RHLinux's locale is of zh_CN.gbk, I found that the Date date = files[i].lastModified() is 8 hours before the actual modified time.
Well, I think when your server is printing date format as "Mar-09-2006-01:45", not the language of your own country(Chinese, German, etc.), you may try the code below:

String sFileRemote = files[i].getName();
Date timeLastModified = ftp.modtime(sFileRemote);
timeLastModified.toString();


and as my tests, I got the right modified time of all the files on remote FTP server, and I guess it's because the modtime(String) method converts the Date of GMTstring to some locale string according to the servers settings.

OK, that's what I've got via this using of edtftp~
And THANK YOU, edt guys~

Please log in or register to answer this question.

Categories

...