Advertisement
Guest User

Untitled

a guest
Sep 26th, 2014
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.text.ParseException;
  4. import java.text.SimpleDateFormat;
  5. import java.util.Date;
  6. import java.util.Scanner;
  7.  
  8. public class Problem1 {
  9.  
  10. public static void main(String[] args) throws ParseException {
  11. Scanner input = new Scanner(System.in);
  12. String[] time = input.nextLine().split(":");
  13. int hour = Integer.parseInt(time[0]);
  14. int minutes = Integer.parseInt(time[1]);
  15. int seconds = Integer.parseInt(time[2]);
  16. time = input.nextLine().split(":");
  17. hour -= Integer.parseInt(time[0]);
  18. minutes -= Integer.parseInt(time[1]);
  19. seconds -= Integer.parseInt(time[2]);
  20. if (seconds < 0){
  21. minutes --;
  22. seconds += 60;
  23. }
  24. if (minutes < 0){
  25. hour --;
  26. minutes += 60;
  27. }
  28. System.out.printf("%d:%02d:%02d",hour,minutes,seconds);
  29.  
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement