Java IO Tutorial - Java FileTime.compareTo(FileTime other)


FileTime.compareTo(FileTime other) has the following syntax.

public int compareTo(FileTime other)


In the following code shows how to use FileTime.compareTo(FileTime other) method.

/*  ww w  .  j a v a  2  s  .  c o m*/
import java.nio.file.attribute.FileTime;
import java.util.concurrent.TimeUnit;

public class Main {

  public static void main(String[] args) throws Exception {

    long time = System.currentTimeMillis();
    FileTime fileTime = FileTime.fromMillis(time);
    FileTime fileTime1 = FileTime.from(time,TimeUnit.MILLISECONDS);


The code above generates the following result.