Get the Instant of the ZonedDateTime

Report a typo

Convert the LocalDateTime unit to the Instant type of the given offset and print that unit combined with the number of seconds passed since the Java epoch.

Sample Input 1:

4

Sample Output 1:

1991-04-15T11:00:00Z, toEpochSeconds: 671713200
Write a program in Java 17
import java.util.Scanner;
import java.time.*;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
LocalDateTime localDateTime = LocalDateTime.of(1991, 4, 15, 15, 0);

Instant instant = convertToInstant(localDateTime, scanner.nextInt());
System.out.println(String.format("%s, toEpochSeconds: %d", instant, instant.getEpochSecond()));
}

public static Instant convertToInstant(LocalDateTime localDateTime, int hours) {

}
}
___

Create a free account to access the full topic