Java Data Type How to - Convert LocalDate to a java.sql.TimeStamp


We would like to know how to convert LocalDate to a java.sql.TimeStamp.


import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
/*from w ww.j ava 2  s . c  o  m*/
public class Main {

  public static void main(String[] args) {

  public static Timestamp toTimestamp(LocalDate localDate) {
    Date date = Date.from(localDate.atStartOfDay()
    Timestamp timeStamp = new Timestamp(date.getTime());
    return timeStamp;

The code above generates the following result.