You are given a list of Instant units. Find how many seconds have passed starting from the minimum unit to the maximum unit. For this purpose, you must explore the minusSeconds() method of the Instant class.
Computer scienceProgramming languagesJavaAdditional instrumentsEssential standard classesDate and time
Instant
Min and max Instant units
Report a typo
Sample Input 1:
1991-04-15T17:30:00Z
1995-05-23T17:30:00Z
2011-07-22T17:30:00Z
2022-07-04T18:30:00ZSample Output 1:
985222800Write a program in Java 17
import java.util.*;
import java.time.Instant;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
List<Instant> instantList = createInstantList(scanner);
long result = getMaxMinusMin(instantList);
System.out.println(result);
}
public static List<Instant> createInstantList(Scanner scanner) {
List<Instant> instantList = new ArrayList<>();
instantList.add(Instant.parse(scanner.nextLine()));
instantList.add(Instant.parse(scanner.nextLine()));
instantList.add(Instant.parse(scanner.nextLine()));
instantList.add(Instant.parse(scanner.nextLine()));
return instantList;
}
private static long getMaxMinusMin(List<Instant> instantList) {
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.