LocalDateTime to Instant
LocalDateTime localDateTime = LocalDateTime.now();
Instant instant = localDateTime.toInstant(ZoneOffset.UTC);
instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
long timeInSeconds = localDateTime.toEpochSecond(ZoneOffset.UTC);
instant = Instant.ofEpochSecond(timeInSeconds);
Instant to LocalDateTime
LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault());
long timeInSeconds = 1567109422L;
localDateTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timeInSeconds), ZoneId.systemDefault());
localDateTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(timeInSeconds, 0), ZoneId.systemDefault());
long timeInMillis = 1567109422123L;
localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeInMillis), ZoneId.systemDefault());
localDateTime = Timestamp.from(Instant.now()).toLocalDateTime();