In the Microsoft Spec, DATETIME
is represented as 2 32-bit integers: low
and high
Reference: https://docs.microsoft.com/en-us/open
Ah I was barking up the wrong tree when I split the bytes in half like that.
Basically it's just saying that the units are in 100ns.
And the Epoch has a different base time too. So you have to add the offset as well.
So it is:
private static final long DATETIME_EPOCH_DIFF_1601;
static {
LocalDateTime time32Epoch1601 = LocalDateTime.of(1601, Month.JANUARY, 1, 0, 0);
Instant instant = time32Epoch1601.atZone(ZoneOffset.UTC).toInstant();
DATETIME_EPOCH_DIFF_1601 = (instant.toEpochMilli() - Instant.EPOCH.toEpochMilli()) / 1000;
}
Instant answer = Instant.ofEpochSecond(fullval / 10000000 + DATETIME_EPOCH_DIFF_1601)