Assuming you have a string that represents epoch time in seconds (as you have not told us what your Object
actually is), first convert it to a long
:
long epoch = Long.parseLong("1395500668");
You’ll then need to convert it to milliseconds:
epoch *= 1000;
Then you can convert it to a java.util.Date
using the Date
constructor that takes millisecond epoch time:
Date date = new Date(epoch);
And finally you can format that Date
as a string using standard formatting techniques.
4
solved How to convert Object as timestamp to formatted date [closed]