How to Convert LocalDate to Date in Java 8 and Above

We can use the Date.from(Instant instant) method to convert a LocalDate to a Date.


Note: We will need to use ZoneId.systemDefault() to get the default time zone.


Example:

package org.code2care.examples;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;

public class ExampleStringToDateJava {

    public static void main(String... args) {

        LocalDate localDate = LocalDate.now();
        Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
        System.out.println(date);

    }

}

Output:

Wed Oct 18 00:00:00 CDT 2023

Convert LocalDate to Date Object Java Example

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!