Last active
January 27, 2023 16:12
-
-
Save 0xffan/9bd8749935cdeb815c9f to your computer and use it in GitHub Desktop.
Parse date from Windows epoch timestamp.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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