create java.util.Date from LocalDate - Java java.time

Java examples for java.time:LocalDate

Description

create java.util.Date from LocalDate

Demo Code


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

public class Main {
    public static Date createDate(int year, Month month, int day) {
        LocalDate localDate = LocalDate.of(year, month, day);
        return localDateToDate(localDate);
    }//from w  w w  .j  a  v a2s  .com

    public static Date localDateToDate(LocalDate localDate) {
        return Date.from(localDate.atStartOfDay(ZoneId.systemDefault())
                .toInstant());
    }
}

Related Tutorials