Here you can find the source of toTimestamp(Date date)
public static Timestamp toTimestamp(Date date)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Date; public class Main { public static Timestamp toTimestamp(Date date) { return toTimestamp(toLocalDateTime(date)); }//w w w . ja v a2 s. co m public static Timestamp toTimestamp(LocalDateTime date) { return Timestamp.valueOf(date); } public static LocalDateTime toLocalDateTime(Date date) { return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); } }