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
Asked
Active
Viewed 1,295 times
2 Answers
5
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.

Jon Skeet
- 1,421,763
- 867
- 9,128
- 9,194
0
You can use Caledar class.
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(millis);

Siva Kumar
- 1,983
- 3
- 14
- 26
-
And then what? `Calendar.toString()` doesn't typically give a nice result, IMO. – Jon Skeet Aug 18 '14 at 16:38