Java LocalDateTime to Date


In this post, we will see how to convert LocalDateTime to Date. Java 8 has introduced a lot of new APIs for Date and time.

Table of Contents

There can be many ways to convert Java LocalDateTime to date.

Using Instant object

You can convert LocalDateTime to date using Instant object which we can from ZonedDateTime. Here is the code for the same:

Using TimeStamp

This is easiest way to convert LocalDateTime to date in Java 8. We can use java.sql.Timestamp to convert LocalDateTime to Date.
The easiest way of getting a java.util.Date from LocalDateTime is to use an extension to the java.sql.Timestamp – available with Java 8:

Here is complete program to convert between LocalDateTime to Date.


Sun Apr 14 00:47:05 IST 2019
2019-04-14 00:47:05.179772

That’s all about Java LocalDateTime to Date in Java 8.


Add Comment