I have a Java application and I need to call into a Windows DLL using JNA. The function I need to call actually takes a __int64
(internally it splits this into low/high portions of the FILETIME
structure). Given a java.util.Date
object, how can I convert it to the appropriate value formatted for a FILETIME
?
This is how you can do it using Java nio
BasicFileAttributes attr = Files.readAttributes(filePath, BasicFileAttributes.class);
DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
Date d = new Date(attr.creationTime().toMillis()); //attr.creationTime() returns a FileTime
System.out.println(df.format(d));
好的,我想我弄清楚了:
long date = (new Date().getTime() + 11644473600000L) * 10000L;
JNA provides some static methods on the FILETIME class which is located in the Platform jar.
FILETIME.dateToFileTime( Date date );
FILETIME.filetimeToDate( int high, int low );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.