Converting Instant instance to Date instance

In this post under DateTime, I will show how to convert an instance of “Instant” class to “Date” instance.

Below is the code to that will do the conversion.

    Instant instant =;
    Date date = Date.from(instant);

“now” static method of “Instant” class will return an “Instant” instance representing the current date time.

Then we call “from” static method of “Date” class and pass the previously created “Instant” instance as an argument.

This static method will be creating a “Date” instance representing the same date time stored in “Instant” instance.

In this way we can convert an “Instant” instance to “Date” instance.

Leave a Reply