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