Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Exam21Sep14_01_Timespan {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- String[] end = input.nextLine().split(":");
- String[] start = input.nextLine().split(":");
- long endTime = Long.parseLong(end[2]) + Long.parseLong(end[1]) * 60 + Long.parseLong(end[0]) * 3600;
- long startTime = Long.parseLong(start[2]) + Long.parseLong(start[1]) * 60 + Long.parseLong(start[0]) * 3600;
- long timeSpan = endTime - startTime;
- long hours = timeSpan / 3600;
- long minutes = (timeSpan % 3600) / 60;
- long seconds = (timeSpan % 3600) % 60;
- System.out.printf("%d:%02d:%02d", hours, minutes, seconds);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement