Java IO Tutorial - Java FileTime.equals(Object obj)








Syntax

FileTime.equals(Object obj) has the following syntax.

public boolean equals(Object obj)

Example

In the following code shows how to use FileTime.equals(Object obj) method.

/*w  w w. ja  v a2  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);
    
    
    System.out.println(fileTime.equals(fileTime1));

  }
}

The code above generates the following result.