@Override public void setTimestamp(final Path file, final Long modified) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting timestamp for %s due to previous failure %s", file, failure.getMessage())); } throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", failure, file); } try { final MDTMSecondsDateFormatter formatter = new MDTMSecondsDateFormatter(); // The utime() function sets the access and modification times of the named // file from the structures in the argument array timep. // The access time is set to the value of the first element, // and the modification time is set to the value of the second element // Accessed date, modified date, created date if(!session.getClient().sendSiteCommand(String.format("UTIME %s %s %s %s UTC", file.getAbsolute(), formatter.format(new Date(System.currentTimeMillis()), TimeZone.getTimeZone("UTC")), formatter.format(new Date(modified), TimeZone.getTimeZone("UTC")), formatter.format(new Date(modified), TimeZone.getTimeZone("UTC"))))) { throw failure = new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } } }
@Override public void setTimestamp(final Path file, final Long modified) throws BackgroundException { if(failure != null) { if(log.isDebugEnabled()) { log.debug(String.format("Skip setting timestamp for %s due to previous failure %s", file, failure.getMessage())); } throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", failure, file); } try { final MDTMSecondsDateFormatter formatter = new MDTMSecondsDateFormatter(); if(!session.getClient().setModificationTime(file.getAbsolute(), formatter.format(modified, TimeZone.getTimeZone("UTC")))) { throw failure = new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file); } } }