Java FileTime convert to Instant

Description

Java FileTime convert to Instant

import java.nio.file.attribute.FileTime;
import java.time.Instant;
import java.util.concurrent.TimeUnit;

public class Main {
  public static void main(String[] args) {
     long time = System.currentTimeMillis();
     FileTime fileTime = FileTime.from(time, TimeUnit.MILLISECONDS);
     System.out.println(fileTime);
     /*from w  ww . ja v a  2  s.  co  m*/
     Instant ins = fileTime.toInstant();
     
     System.out.println("ins:"+ins);
  }
}



PreviousNext

Related