LocalDate to Java Date via Instant - Java java.time

Java examples for java.time:Instant

Description

LocalDate to Java Date via Instant

Demo Code


//package com.java2s;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;

public class Main {
    public static Date toJavaDate(LocalDate localDate) {
        Instant localDateInstant = Instant.from(localDate.atStartOfDay()
                .atZone(ZoneId.systemDefault()));
        return Date.from(localDateInstant);
    }/*w w w  . j  av a 2s.  co m*/
}

Related Tutorials