How to convert an Instant to a date format?

The Solution to How to convert an Instant to a date format? is


If you want to convert an Instant to a Date:

Date myDate = Date.from(instant);

And then you can use SimpleDateFormat for the formatting part of your question:

SimpleDateFormat formatter = new SimpleDateFormat("dd MM yyyy HH:mm:ss");
String formattedDate = formatter.format(myDate);

~ Answered on 2015-06-02 10:13:38


Most Viewed Questions: