import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str1 = sc.nextLine(); String str2 = sc.nextLine(); String[] a = str1.split(":"); String[] b = str2.split(":"); int t1 = Integer.parseInt(a[0]) * 3600 + Integer.parseInt(a[1]) * 60 + Integer.parseInt(a[2]); int t2 = Integer.parseInt(b[0]) * 3600 + Integer.parseInt(b[1]) * 60 + Integer.parseInt(b[2]); int num = Math.abs(t1 - t2); int h = num/3600; int m = num%3600/60; int s = num%3600%60; System.out.println(String.format("%d:%02d:%02d",h,m,s)); } } |
Double click to view unformatted code.