I am trying to create a chat application in android studio.
I have a timestamp, say this
1694603269045
Now I want to convert this timestamp into human readable way like one minute ago or one hour ago. I will is into my storyView mode where a user will be able to see when his friends uploaded a story/status.
I need this as String, like
one minute ago
so that I can use it in a TextView. Is that possible?
I tried to find some solutions but most of them are related to javascript where I need it in Java.
The String needs to be like this:

Is that possible in Java in some way? Thank You.
You can create an
Instantfrom your timestamp and calculate theDurationbetween it andInstant.now().This just printed
You will have to check which values (hours, minutes, seconds and so on) are actually zero if you want to switch from minutes to hours when minutes are 0, but hours aren't, for example. This would print
0 minutes agoin 13 minutes and you may want to cover situations like that.