Converting Date instance to Instant instance

In this post under DateTime, I will show how to convert an instance of “Date” class to “Instant” instance. Below is the code to that will do the conversion. Date date = new Date(); Instant instant = date.toInstant(); As shown in the above code snippet, first we create a “Date” instance and store in “date”…… Continue reading Converting Date instance to Instant instance

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 = Instant.now(); Date date = Date.from(instant); “now” static method of “Instant” class will return an “Instant” instance representing the current date time. Then we…… Continue reading Converting Instant instance to Date instance