import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String string = scanner.nextLine(); String str = scanner.nextLine(); String[] a = string.split(":"); String[] b = str.split(":"); int h1 = Integer.parseInt(a[2]) + Integer.parseInt(a[1]) * 60 +Integer.parseInt(a[0]) * 3600; int h2 = Integer.parseInt(b[2]) + Integer.parseInt(b[1]) * 60 +Integer.parseInt(b[0]) * 3600; int t = Math.abs(h1 - h2); int h = t / 3600; int m = t % 3600 / 60; int s = t % 3600 % 60; System.out.printf("%d:%02d:%02d",h,m,s); } } |
Double click to view unformatted code.