1
2 // 2021-03-24 16:48:05.591
3 Timestamp timestamp = new Timestamp(System.currentTimeMillis());
4
5 // 2021-03-24 16:48:05.591
6 Date date = new Date();
7 Timestamp timestamp2 = new Timestamp(date.getTime());
8
9 // convert Instant to Timestamp
10 Timestamp ts = Timestamp.from(Instant.now())
11
12 // convert ZonedDateTime to Instant to Timestamp
13 Timestamp ts = Timestamp.from(ZonedDateTime.now().toInstant()));
14
15 // convert Timestamp to Instant
16 Instant instant = ts.toInstant();