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