private long parse(String stamp) {
      long ms = 0L;
      String seconds = stamp;

      if (stamp.contains(":")) {
         String[] tokens = stamp.split(":");
         if (tokens.length > 3) {
            throw new IllegalArgumentException();
         }
         // Converts hours and minutes in milliseconds, handling the 
         // different cases with a simple for loop, using the following
         //  Hours * 3600 = Seconds (3600 = 60^2)
         //  Minutes * 60 = Seconds   (60 = 60^1)
         for (int i = 0; i < tokens.length - 1; i++) {
            long power = (long) Math.pow(60, tokens.length - i - 1);
            ms += Long.valueOf(tokens[i]) * power * 1000L;
         }
         seconds = tokens[tokens.length - 1];
      }
      double ss = Double.parseDouble(seconds);
      return ms + (long) (ss * 1000.0);
   }