0

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

petabyte
  • 1,487
  • 4
  • 15
  • 31

2 Answers2

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