date from timestamp java code example
Example 1: java timestamp
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
Copy
Example 2: java timestamp from string
LocalDateTime timestamp=LocalDateTime.parse("2007-12-03T10:15:30");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd HH:mm");
LocalDate parsedDate = LocalDate.parse("1970 01 01 00:00", formatter);
Example 3: date to timestamp java
All you need to do is change the string within the java.text.SimpleDateFormat constructor to: "MM-dd-yyyy HH:mm:ss".
Just use the appropriate letters to build the above string to match your input date.