@Override
    public void setTimestamp(final Path file, final TransferStatus status) throws BackgroundException {
        try {
            if(null != status.getModified()) {
                // We must both set the accessed and modified time. See AttribFlags.SSH_FILEXFER_ATTR_V3_ACMODTIME
                // All times are represented as seconds from Jan 1, 1970 in UTC.
                final long atime = Timestamp.toSeconds(System.currentTimeMillis());
                final long mtime = Timestamp.toSeconds(status.getModified() != null ? status.getModified() : System.currentTimeMillis());
                final FileAttributes attrs = new FileAttributes.Builder().withAtimeMtime(atime / 1000, mtime / 1000).build();
                session.sftp().setAttributes(file.getAbsolute(), attrs);
            }
        }
        catch(IOException e) {
            throw new SFTPExceptionMappingService().map("Cannot change timestamp of {0}", e, file);
        }
    }
@Test
    public void testSetTimestamp() throws Exception {
        final Path home = new SFTPHomeDirectoryService(session).find();
        final Path test = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
        new SFTPTouchFeature(session).touch(test, new TransferStatus());
        final long modified = System.currentTimeMillis();
        new SFTPTimestampFeature(session).setTimestamp(test, modified);
        assertEquals(TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(modified)), new SFTPAttributesFinderFeature(session).find(test).getModificationDate());
        assertEquals(TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(modified)), new DefaultAttributesFinderFeature(session).find(test).getModificationDate());
        new SFTPDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());

    }