I want to display the user's last sign-in date in Kotlin
To display the user's last sign-in date in a Kotlin "style", please use the following lines of code:
FirebaseAuth.getInstance().currentUser?.metadata?.apply {
val lastSignInDate = Date(lastSignInTimestamp)
Toast.makeText(this, lastSignInDate.toString() ,Toast.LENGTH_SHORT).show()
}
The result will be a Toast message containing the String representation of the "lastSignInDate" object, which is an object of type Date. Let's suppose the user has signed in last time yesterday, the message might look similar to this:
Wed Mar 31 11:20:10 GMT+03:00 2021
If needed, you can also format the Date in a more readable way, as explained in the answer from the following post: