내 코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String now = scan.nextLine();
String target = scan.nextLine();
int[] aNow = makeIntArr(now);
int[] aTarget = makeIntArr(target);
String result = "";
for (int i = 2; i >= 0; i--) {
int sleep = aTarget[i] - aNow[i];
if (sleep < 0) {
if (i > 0) {
aTarget[i - 1]--;
sleep = 60 + sleep;
} else {
sleep = 24 + sleep;
}
}
result = String.format(":%02d%s", sleep, result);
}
result = ":00:00:00".equals(result) ? ":24:00:00" : result;
System.out.println(result.substring(1));
}
private static int[] makeIntArr(String ss) {
int idx = 0;
int[] arr = new int[3];
for (String s: ss.split(":"))
arr[idx++] = Integer.parseInt(s);
return arr;
}
}