Proper way to find newest file in a directory
some minore issues only...

naming / return type

public static Path getLatestFile() assumes that you return only ONE file, but it's easily possible that you have two files of the same date... so you should maybe return a Set&lt;Path&gt; from your method getLatestFiles(). This method would return all files with the latest time stamp.

use a logging framework

you should write infos into a proper logging stream:

System.out.println("Latest file: " + pathToReturn + " - " + attr.creationTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());


note:

you could write the corresponding information directly inside the loop.  

for (Path path : pathSet) {
        attr = getBasicFileAttributes(path);
        if (attr.creationTime().toMillis() &gt; fileTime) {
        fileTime = attr.creationTime().toMillis();
            pathToReturn = path;
            //here
            System.out.println("Latest file: " + pathToReturn + " - " + attr.creationTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
        }
    }

    //instead of here:
    //attr = getBasicFileAttributes(pathToReturn);
    //System.out.println("Latest file: " + pathToReturn + " - " + attr.creationTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());


more significant code (tell, don't ask):

maybe it's just my style but i would really directly return what is said:

private static BasicFileAttributes getBasicFileAttributes(Path pathToReturn) throws IOException {
    return Files.readAttributes(pathToReturn, BasicFileAttributes.class);
}


use a test case

instead of testing your code in a main-methode write a junit test. that makes the code clearer to read and you can get rid of the methods getFilesFromDirectory() and iteratePaths() which are only for testing.

ever since the test methods are still in review let me advise you about these:

possible NPE

it's possible to create a NullPointerException:

Stream&lt;Path&gt; stream = null;
try {...} catch (IOException e) {...}
//if an exception is raised within this block above an NPE will be thrown!
stream.close();


maybe you could consider a try-with-resources block? maybe you don't care because it's a mere test method, haha =)

use a Logger / Handle Exceptions

what do you do if an exception really happens? you should implement the actions that should happen in case of exception - not just printing to stacktrace:

Stream&lt;Path&gt; stream = null;
    try {...} catch (IOException e) {
        //don't print - take actions instead!
        //e.printStackTrace();
    }


as said above, maybe you don't care because it's a mere test method...