public static int parseTime(String input){
  Scanner scanner=new Scanner(input.trim());
  scanner.useLocale(Locale.ENGLISH);
  int time;
  if (input.contains(":")) {
    scanner.useDelimiter(":");
    if (!scanner.hasNextLong()) {
      return 0;
    }
    long minutes=scanner.nextLong();
    if (minutes < 0) {
      return 0;
    }
    if (!scanner.hasNextDouble()) {
      return 0;
    }
    double seconds=scanner.nextDouble();
    if (seconds < 0.0 || seconds >= 60.0) {
      return 0;
    }
    time=(int)(60000 * minutes + 1000 * seconds);
  }
 else {
    if (!scanner.hasNextDouble()) {
      return 0;
    }
    double seconds=scanner.nextDouble();
    if (seconds < 0.0) {
      return 0;
    }
    time=(int)(1000 * seconds);
  }
  return 10 * ((time + 5) / 10);
}

public static int parseTime ( String input ) { Scanner scanner = new Scanner ( input . trim ( ) ) ; scanner . useLocale ( Locale . ENGLISH ) ; int time ; if ( input . contains ( ":" ) ) { scanner . useDelimiter ( ":" ) ; if ( ! scanner . hasNextLong ( ) ) { return 0 ; } long minutes = scanner . nextLong ( ) ; if ( minutes < 0 ) { return 0 ; } if ( ! scanner . hasNextDouble ( ) ) { return 0 ; } double seconds = scanner . nextDouble ( ) ; if ( seconds < 0.0 || seconds >= 60.0 ) { return 0 ; } time = ( int ) ( 60000 * minutes + 1000 * seconds ) ; } else { if ( ! scanner . hasNextDouble ( ) ) { return 0 ; } double seconds = scanner . nextDouble ( ) ; if ( seconds < 0.0 ) { return 0 ; } time = ( int ) ( 1000 * seconds ) ; } return 10 * ( ( time + 5 ) / 10 ) ; }
converts times such as 00 : 00 . 00 into int for storage code shamelessly stolen from prisma puzzle timer ( love you ) .
