Timestamp from LDAP (ActiveDirectories lastLogonTimestamp)

If I get a Timestamp it's ms since Epoch
1143584229619

But in LDAP I get a value from the timestamp more like
127877417297554938

First though was maybe ms since time of '01/01/0000' or something but it does not add up that way.

Does anyone know what the timestamp maybe; and how I can convert it into something Java can use.

Thanks in advance.



Answer this question

Timestamp from LDAP (ActiveDirectories lastLogonTimestamp)

  • Brent Mullet

    Hi

    lastLogonTimeStamp seems to be the no of 100 nano second intervals starting from 0000 hrs 1/1/1601.

    This is similiar to windows file time format and .NET has support to create a System.DateTime object out of this value.. Note the sample here, using the long value that you had provided and watch the date being recreated..

    .NET Sample :
    import System.*;
    class Test
    {
    public static void main(String args[])

    {
    DateTime dt=DateTime.FromFileTime(127877417297554938L);
    System.out.println(dt);
    }
    }

    Java Sample :
    If you want to create a java date object out of this value, please try following this sample, where i have used an adjustment factor to convert the lastLogonTimestamp value into a Date object..

    import java.util.*;
    class Test
    {
    public static void main(String args[])
    {

    long llastLogonAdjust=11644473600000L; // adjust factor for converting it to java
    //date Epoch
    Date lastLogon = new Date(127877417297554938L/10000-llastLogonAdjust); //
    System.out.println(lastLogon);
    }
    }

    Thanks

    With regards
    Ashwin Raja


  • Timestamp from LDAP (ActiveDirectories lastLogonTimestamp)