LDAP Timestamp

The unix/epox timestamp is not used by the active directories. Instead the number of ticks from 1st Jan 1601 is used. 

CAUTION: the number of ticks is not really in milliseconds, in fact

1 millisecond = 10000 ticks.

Now, how to covert no of ticks to a human readable date. The difference between the two dates in seconds is 11644473600 seconds.

Thus, lets say we have x ticks.

milliseconds = x / 10000
seconds = milliseconds / 1000

unixTimestamp = seconds –  11644473600;

Now, simply use java.util.Date to convert unix timestamp to a date data type.

private static Date getDateFromTicks(long ticks) {
    long milliseconds = ticks/10000;
    long unixTimestamp = milliseconds – 11644473600000L;
    return new Date(unixTimestamp);


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: