Skip to content

Instantly share code, notes, and snippets.

@0xffan
Last active January 27, 2023 16:12
Show Gist options
  • Save 0xffan/9bd8749935cdeb815c9f to your computer and use it in GitHub Desktop.
Save 0xffan/9bd8749935cdeb815c9f to your computer and use it in GitHub Desktop.
Parse date from Windows epoch timestamp.
// The difference between the Windows epoch (1601-01-01 00:00:00) and the Unix epoch (1970-01-01 00:00:00) in milliseconds: 11644473600000L.
private final static long WINDOWS_UNIX_EPOCH_DIFF_MILLISECONDS = 11644473600000L;
public static Date parseDateFromADTimestamp(String strADTimestamp) {
long adTimestamp = Long.parseLong(strADTimestamp);
long millisecondsTime = (adTimestamp / 10000) - WINDOWS_UNIX_EPOCH_DIFF_MILLISECONDS;
Date date = new Date(millisecondsTime);
return date;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment