LocalDateTime To java.sql.Date - Java java.time

Java examples for java.time:LocalDateTime

Description

LocalDateTime To java.sql.Date

Demo Code


//package com.java2s;

import java.time.LocalDateTime;
import java.time.ZoneId;

public class Main {
    public static java.sql.Date localTimeToDate(LocalDateTime lt) {
        return new java.sql.Date(lt.atZone(ZoneId.systemDefault())
                .toInstant().toEpochMilli());
    }/*from   ww  w .j  a  v  a 2 s.  co  m*/
}

Related Tutorials