Convert between LocalDate to java.sql.Date

Java 8 examples to convert from LocalDate to java.sql.Date and vice versa.

1. Convert java.sql.Date to LocalDate

Use java.sql.Date.toLocalDate() method to get LocalDate from a java.sql.Date.

//Get SQL date instance
java.sql.Date sqlDate = new java.sql.Date(new Date().getTime());

//Get LocalDate from SQL date
LocalDate localDate = sqlDate.toLocalDate();

System.out.println( localDate );    //2022-01-15

2. Convert LocalDate to java.sql.Date

Use java.sql.Date.valueOf() method to get SQL date from a LocalDate.

//Local date instance
LocalDate localDate =;

//Get LocalDate from SQL date
java.sql.Date sqlDate = java.sql.Date.valueOf( localDate );

System.out.println( sqlDate );  //2022-01-15    

Happy Learning !!

Sourcecode on Github

Comments are closed for this article!

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.