fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10.  
  11. public static int hour2minutes(String fullhour)
  12. {
  13. String[] parts = fullhour.split(":");
  14.  
  15. int hour = Integer.parseInt(parts[0]);
  16. int min = Integer.parseInt(parts[1]);
  17.  
  18. return (hour* 60) + min; //Pega o total
  19. }
  20.  
  21. public static void main (String[] args) throws java.lang.Exception
  22. {
  23. System.out.println(hour2minutes("12:39"));
  24. System.out.println(hour2minutes("16:20"));
  25. System.out.println(hour2minutes("23:59"));
  26. }
  27. }
Success #stdin #stdout 0.06s 3359744KB
stdin
Standard input is empty
stdout
759
980
1439