Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.Scanner;
- public class Problem1 {
- public static void main(String[] args) throws ParseException {
- Scanner input = new Scanner(System.in);
- String[] time = input.nextLine().split(":");
- int hour = Integer.parseInt(time[0]);
- int minutes = Integer.parseInt(time[1]);
- int seconds = Integer.parseInt(time[2]);
- time = input.nextLine().split(":");
- hour -= Integer.parseInt(time[0]);
- minutes -= Integer.parseInt(time[1]);
- seconds -= Integer.parseInt(time[2]);
- if (seconds < 0){
- minutes --;
- seconds += 60;
- }
- if (minutes < 0){
- hour --;
- minutes += 60;
- }
- System.out.printf("%d:%02d:%02d",hour,minutes,seconds);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement