Answers for "date from timestamp java"

8

java timestamp

Timestamp timestamp = new Timestamp(System.currentTimeMillis());
//2016-11-16 06:43:19.77
Copy
Posted by: Guest on April-12-2020
1

java timestamp now

// 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();
Posted by: Guest on April-01-2021
3

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);
Posted by: Guest on April-14-2021
-1

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.
Posted by: Guest on March-05-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language