Java Convert SQL Date to LocalDate

Tags: Java SQL Date Java LocalDate Java 8

In this Java core tutorial we learn how to convert a java.sql.Date object to a java.time.LocalDate object in Java programming language.

How to convert SQL Date to LocalDate in Java

In Java, with a given SQL Date object we can use the Date.toLocalDate() method to convert it to a LocalDate object as the following example Java code.

ConvertSQLDateToLocalDateExample1.java

import java.sql.Date;
import java.time.LocalDate;

public class ConvertSQLDateToLocalDateExample1 {
    public static void main(String... args) {
        Date date = new Date(System.currentTimeMillis());

        // Convert SQL Date object to LocalDate object
        LocalDate localDate = date.toLocalDate();

        System.out.println("SQL Date: " + date);
        System.out.println("LocalDate: " + localDate);
    }
}
The output as below.
SQL Date: 2022-05-23
LocalDate: 2022-05-23

Happy Coding 😊

Java Convert LocalDate to SQL Date

Java Convert Instant to SQL Date

Java Convert LocalDateTime to SQL Date

Java Convert ZonedDateTime to SQL Date

Java Convert OffsetDateTime to SQL Date

Java Convert Date to SQL Date

Java Convert Calendar to SQL Date

Java Convert GregorianCalendar to SQL Date

Java Convert SQL Date to LocalDateTime

Java Convert SQL Date to ZonedDateTime

Java Convert SQL Date to OffsetDateTime

Java Convert SQL Date to Calendar

Java Convert SQL Date to GregorianCalendar

Java Convert SQL Date to Instant