Example usage for org.apache.commons.net.ftp FTPFile getTimestamp

List of usage examples for org.apache.commons.net.ftp FTPFile getTimestamp

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPFile getTimestamp.

Prototype

public Calendar getTimestamp() 

Source Link

Document

Returns the file timestamp.

Usage

From source file:ro.kuberam.libs.java.ftclient.FTP.FTP.java

private static void _generateResourceElement(XMLStreamWriter xmlWriter, FTPFile resource, InputStream is,
        String resourceAbsolutePath) throws IOException, Exception {

    String resourceName = resource.getName();
    String resourceType = ((resource.getType() == 1) ? "directory"
            : (((resource.getType() == 0) ? "file" : "link")));
    Calendar resourceTimeStamp = resource.getTimestamp();
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ");
    String lastModified = formatter.format(resourceTimeStamp.getTimeInMillis());
    lastModified = lastModified.replace(" ", "T");
    lastModified = lastModified.substring(0, 22) + ":" + lastModified.substring(22, 24);
    long resourceSize = resource.getSize();
    String user = resource.getUser();
    String userGroup = resource.getGroup();
    String permissions = resource.getRawListing().substring(0, 10);
    String linkTo = resource.getLink();

    GenerateResourceElement.run(is, xmlWriter, modulePrefix, moduleNsUri, resourceName, resourceType,
            resourceAbsolutePath, lastModified, resourceSize, user, userGroup, permissions, linkTo);
}

From source file:uk.co.nickthecoder.pinkwino.optional.publish.FtpSync.java

public boolean needsUploading(File localFile, FTPFile remoteFile) {
    long remoteTime = remoteFile.getTimestamp().getTimeInMillis();
    long localTime = localFile.lastModified();

    return remoteTime < localTime;
}

From source file:uk.trainwatch.io.ftp.FTPClient.java

/**
 * Simple test to see if a remote file should be retrieved.
 * <p>// w ww .ja  v  a 2 s . c o m
 * This returns true if file does not exist, if the lengths don't match or the remote file's date is newer than the local file
 * <p>
 * @param file
 * @param ftp
 *             <p>
 * @return
 * @throws java.io.IOException
 */
default boolean isFileRetrievable(File file, FTPFile ftp) throws IOException {
    return !file.exists() || file.length() != ftp.getSize()
            || file.lastModified() < ftp.getTimestamp().getTimeInMillis();
}