Is there a solution without using the Date
class which is deprecated, and without having to specify some format like in SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
, since I just want any readable format? Thanks
The Date
class isn't deprecated - just many of its constructors/methods are.
You can still use:
String text = new Date(millisSinceEpoch).toString();
You can't change the string format - it will always use the system default time zone, for example - but it may be enough for you.
Personally I'd still use either SimpleDateFormat
or better yet java.time
or Joda Time, but if you really really don't want to do that, this might be good enough.
See more on this question at Stackoverflow