local Date To Date via default ZoneId - Java java.time

Java examples for java.time:ZoneId

Description

local Date To Date via default ZoneId

Demo Code


//package com.java2s;
import java.time.LocalDate;
import java.time.ZoneId;

import java.util.Date;

public class Main {
    public static Date localDateToDate(LocalDate date) {
        if (date == null) {
            return null;
        }// ww  w . j  av a  2 s  .c  o  m
        return Date.from(date.atStartOfDay(ZoneId.systemDefault())
                .toInstant());
    }
}

Related Tutorials