Review the code below. I used Scanner class to get the required tokens.

Java Code:
    String input = "10:11:12";
    Scanner sc = new Scanner(input).useDelimiter(":");
    while (sc.hasNextInt()) {
          int i = sc.nextInt();
          System.out.println(i);
    }