Java library for working with win32 FILETIME?

Are there any Java libraries for working with win32 FILETIME / time intervals ? This is basically a 64-bit timestamp with an interval of 100 ns since January 1, 1601.

(For my specific needs, converting to / from java.util.Date or the corresponding time equivalent joda will do, although I will need access at least to the microsecond resolution, which does not seem to provide.)

+5
source share
2 answers

If you're ok with a resolution in milliseconds, this will work:

/** Difference between Filetime epoch and Unix epoch (in ms). */
private static final long FILETIME_EPOCH_DIFF = 11644473600000L;

/** One millisecond expressed in units of 100s of nanoseconds. */
private static final long FILETIME_ONE_MILLISECOND = 10 * 1000;

public static long filetimeToMillis(final long filetime) {
    return (filetime / FILETIME_ONE_MILLISECOND) - FILETIME_EPOCH_DIFF;
}

public static long millisToFiletime(final long millis) {
    return (millis + FILETIME_EPOCH_DIFF) * FILETIME_ONE_MILLISECOND;
}

Converting from ms to a Date object is pretty simple at this point.

+8
source

JNI... ( Windows, unix)

, ++, , Java Native Interface.

, , ( i- node).

EDIT: - , Date4J 9 , , Joda.

0

All Articles