local LocalDateTime To java.sql.Timestamp - Java java.time

Java examples for java.time:LocalDateTime

Description

local LocalDateTime To java.sql.Timestamp

Demo Code


//package com.java2s;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.ZoneId;

public class Main {
    public static Timestamp localDataTimeToTimestamp(
            LocalDateTime localDateTime) {
        return localDateTime != null ? Timestamp.from(localDateTime.atZone(
                ZoneId.systemDefault()).toInstant()) : null;
    }/*  w ww.j a  v  a 2s  .co  m*/
}

Related Tutorials