Con le librerie dell'Apache non ci sono riuscito.
Ho cmq risolto con le librerie della zehon che tra le altre cose sono anche più semplici da usare e supportano anche l'SFTP.
Ecco la mia classe per ottenere la data di un file situato su un server FTP:
Codice PHP:
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.zehon.ftp.FTPClient;
public class GetModificationTime {
public static void main(String[] args) {
String host = "localhost";
String username = "myUser";
String password = "myPwd";
String filePath = "/test/test.txt";
try {
FTPClient ftpClient = new FTPClient(host, username, password);
long modTime = ftpClient.getLastModificationTime(filePath);
// Format time
Date date = new Date(modTime);
Format formatter = new SimpleDateFormat("dd-MMM-yy HH:mm:ss");
String s = formatter.format(date);
System.out.println(s);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Spero possa essere utile a qualche altro utente