LocalDateTime localtime = LocalDateTime.now();import java.text.SimpleDateFormat; import java.util.Date; public class SimpleTesting{ public static void main(String[] args) { SimpleDateFormat date = new SimpleDateFormat("yyyy.MM.dd.HH:mm:ss"); String timeStamp = date.format(new Date()); System.out.println("Current Time Stamp: "+timeStamp); } } // 2021-03-24 16:48:05.591 Timestamp timestamp = new Timestamp(System.currentTimeMillis()); // 2021-03-24 16:48:05.591 Date date = new Date(); Timestamp timestamp2 = new Timestamp(date.getTime()); // convert Instant to Timestamp Timestamp ts = Timestamp.from(Instant.now()) // convert ZonedDateTime to Instant to Timestamp Timestamp ts = Timestamp.from(ZonedDateTime.now().toInstant())); // convert Timestamp to Instant Instant instant = ts.toInstant();import java.time.Instant; public class Main { public static void main(String[] args) { Instant timestamp = Instant.now(); System.out.println("Current timestamp: " + timestamp); } }