The until() method

Report a typo

Compare how many hours will pass from the date-time represented by the ZonedDateTime variable until that represented by the OffsetDateTime variable.

Sample Input 1:

1995
5
21
13
0

Sample Output 1:

35928
Write a program in Java 17
import java.util.Scanner;
import java.time.*;
import java.time.temporal.ChronoUnit;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

ZoneId yerevanZone = ZoneId.of("Asia/Yerevan");
ZoneOffset yerevanOffset = ZoneOffset.of("+04:00");

LocalDateTime localDateTime1 = LocalDateTime.of(1991, 4, 15, 13, 0);
LocalDateTime localDateTime2 = createLocalDateTime(scanner);
ZonedDateTime zonedDateTime = ZonedDateTime.of(localDateTime1, yerevanZone);
OffsetDateTime offsetDateTime = OffsetDateTime.of(localDateTime2, yerevanOffset);

System.out.println(getHoursUntil(zonedDateTime, offsetDateTime));
}

public static LocalDateTime createLocalDateTime(Scanner scanner) {
int year = scanner.nextInt();
int month = scanner.nextInt();
int dayOfMonth = scanner.nextInt();
int hour = scanner.nextInt();
int minute = scanner.nextInt();

return LocalDateTime.of(year, month, dayOfMonth, hour, minute);
}

public static long getHoursUntil(ZonedDateTime zonedDateTime, OffsetDateTime offsetDateTime) {

}
}
___

Create a free account to access the full topic