Unable to print lastLogon after converting to Date format using Date tool in Email Template written in Apache Velocity

I tried the below code to convert date/time sent from active directory to a readable format and this worked.

#set( $lastLogon = "N/A" )
#set( $lastLoginRaw = $lnk.getAttribute("pwdLastSet") )
		
#if($lastLoginRaw)
	#set($millisSince1601 = $lastLoginRaw / 10000)
	#set($epochDifference = 11644473600000)  ## milliseconds between 1601 and 1970
	#set($javaMillis = $millisSince1601 - $epochDifference)
	
	#set($dateObject = $spTools.getClass().forName("java.util.Date").newInstance())
	#set($date = $dateObject.setTime($javaMillis))
	#set($formattedDate = $spTools.formatDate($dateObject, "EEEEE, MMMMM dd, yyyy"))
#end