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

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap