string to timestamp java code example
Example 1: new date to utc string java
myJavaUtilDate.toInstant().toString()
// output = "2020-05-05T19:46:12.912Z"
Example 2: java timestamp from string
//parse ISO local date time String
LocalDateTime timestamp=LocalDateTime.parse("2007-12-03T10:15:30");
//parse custom String
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd HH:mm");
LocalDate parsedDate = LocalDate.parse("1970 01 01 00:00", formatter);