Hi Anutosh,
You can use the following query builder query to fetch the user's last logon time.
select SI_NAME,SI_USERFULLNAME,SI_LASTLOGONTIME from CI_SYSTEMOBJECTS where si_kind='User'
Extract the output in the excel file using JAVA SDK and you would be able to sort them out as per the date and time.
Hope this helps
~SwapnilY